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 => app(CurrentProperty::class)->id()) ->placeholder('– keine (z. B. Umgebung) –'), Select::make('appearance_ids') ->label('Zeigen in') ->multiple() ->options(fn (): array => Appearance::photoOptions()) ->placeholder('ganzjährig') ->helperText('Leer = ganzjährig. Mit Auswahl erscheint das Foto nur in diesen Erscheinungsbildern – dann vor den ganzjährigen Fotos.') ->dehydrateStateUsing(fn (?array $state): ?array => self::appearanceIds($state)), Toggle::make('is_published') ->label('Auf der Webseite zeigen') ->default(true), ]); } /** * Selected appearances as integers, null for "all year". * * @param array|null $state * @return list|null */ public static function appearanceIds(?array $state): ?array { $ids = array_values(array_unique(array_map('intval', array_filter((array) $state)))); return $ids === [] ? null : $ids; } }