feat/docker-compose-update (#18)

Co-authored-by: jon brookes <marshyon@gmail.com>
Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/18
This commit is contained in:
Jon Brookes 2026-02-08 18:04:18 +01:00
parent fd43495e2d
commit 1a22fd156d
70 changed files with 1068 additions and 745 deletions

View file

@ -7,6 +7,8 @@ use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
use Spatie\MediaLibrary\MediaCollections\Models\Media as SpatieMedia;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;
class MediaForm
{
@ -24,6 +26,7 @@ class MediaForm
Hidden::make('disk')
->default('public'),
FileUpload::make('file')
->multiple() // workaround for Filament v4 single-file bug
->label('File')
->imageEditor()
->imageEditorAspectRatios([
@ -38,22 +41,50 @@ class MediaForm
->acceptedFileTypes(['image/*', 'application/pdf'])
->maxSize(10240)
->required(fn($context) => $context === 'create')
->afterStateHydrated(function (FileUpload $component, $state, $record): void {
if (! $record) {
return;
Log::info('MediaForm afterStateHydrated invoked', ['record_id' => $record?->id, 'state' => $state]);
try {
if (! $record) {
return;
}
$media = $record;
if (! $media instanceof SpatieMedia) {
return;
}
// Construct the correct path: {media_id}/{filename}
$path = $media->id . '/' . $media->file_name;
try {
$disk = $media->disk ?? 'public';
if (Storage::disk($disk)->exists($path)) {
$component->state($path);
}
} catch (\Throwable $e) {
Log::error('MediaForm afterStateHydrated storage check failed', [
'err' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
'disk' => $media->disk ?? null,
'path' => $path,
]);
}
} catch (\Throwable $e) {
Log::error('MediaForm afterStateHydrated unhandled', [
'err' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
'record' => $record?->id,
'state' => $state,
]);
throw $e;
}
$media = $record;
if (! $media instanceof SpatieMedia) {
return;
}
// Construct the correct path: {media_id}/{filename}
$path = $media->id . '/' . $media->file_name;
$component->state($path);
}),
]);
}
}