Files
fewo-stommer/app/Filament/Resources/Photos/Schemas/PhotoForm.php
T
LarsandClaude Opus 5.5 1871c04507
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Fix: photos uploaded in the admin were stored privately and did not show on the website
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>
2026-10-23 17:12:32 +02:00

55 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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),
]);
}
}