The admin upload field used Filament's default disk (FILESYSTEM_DISK=local, private), while imports and the website use the public disk – a photo uploaded in the admin appeared in the photo list but its web sizes returned 403 (e.g. as floor plan picture). The photo collection and the upload field now always use the public disk; a data migration moves photos already stored privately (original and web sizes, folder = media id) to the public disk. Tests for the upload and the migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
PHP
55 lines
2.1 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Resources\Photos\Schemas;
|
||
|
||
use App\Enums\PhotoCategory;
|
||
use App\Models\Photo;
|
||
use App\Models\Property;
|
||
use Filament\Forms\Components\Select;
|
||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Schemas\Schema;
|
||
|
||
class PhotoForm
|
||
{
|
||
public static function configure(Schema $schema): Schema
|
||
{
|
||
return $schema
|
||
->columns(2)
|
||
->components([
|
||
SpatieMediaLibraryFileUpload::make('image')
|
||
->label('Bild')
|
||
->collection(Photo::COLLECTION)
|
||
->disk('public')
|
||
->image()
|
||
->imageEditor()
|
||
->maxSize(25 * 1024)
|
||
->helperText('JPG, PNG oder WebP bis 25 MB. Große Originale sind willkommen – Web-Größen werden automatisch erzeugt.')
|
||
->required()
|
||
->columnSpanFull(),
|
||
TextInput::make('alt_text')
|
||
->label('Bildbeschreibung')
|
||
->helperText('Kurz beschreiben, was zu sehen ist – wichtig für Google und für blinde Besucher.')
|
||
->required()
|
||
->maxLength(255),
|
||
TextInput::make('caption')
|
||
->label('Bildunterschrift (optional)')
|
||
->maxLength(255),
|
||
Select::make('category')
|
||
->label('Kategorie')
|
||
->options(PhotoCategory::class)
|
||
->default(PhotoCategory::Apartment)
|
||
->required(),
|
||
Select::make('property_id')
|
||
->label('Wohnung')
|
||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||
->default(fn (): ?int => Property::query()->value('id'))
|
||
->placeholder('– keine (z. B. Umgebung) –'),
|
||
Toggle::make('is_published')
|
||
->label('Auf der Webseite zeigen')
|
||
->default(true),
|
||
]);
|
||
}
|
||
}
|