Saisonfotos am Foto statt am Erscheinungsbild
Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch" oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden in die Bausteine uebernommen und entfallen dort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d02f3e05c7
commit
791786ed3e
21 files changed
+449
-235
No files matched your search
@@ -3,17 +3,23 @@
|
||||
namespace App\Filament\Resources\Photos\Tables;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Filament\Resources\Photos\Schemas\PhotoForm;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Photo;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PhotosTable
|
||||
{
|
||||
@@ -36,6 +42,12 @@ public static function configure(Table $table): Table
|
||||
->searchable(),
|
||||
TextColumn::make('category')
|
||||
->badge(),
|
||||
TextColumn::make('appearance_ids')
|
||||
->label('Zeigen in')
|
||||
->state(fn (Photo $record): array => $record->appearanceNames())
|
||||
->badge()
|
||||
->color('warning')
|
||||
->icon('heroicon-m-sun'),
|
||||
IconColumn::make('is_published')
|
||||
->boolean()
|
||||
->trueIcon('heroicon-o-eye')
|
||||
@@ -46,6 +58,14 @@ public static function configure(Table $table): Table
|
||||
SelectFilter::make('category')
|
||||
->label('Kategorie')
|
||||
->options(PhotoCategory::class),
|
||||
SelectFilter::make('season')
|
||||
->label('Zeigen in')
|
||||
->options(fn (): array => ['all_year' => 'ganzjährig', ...Appearance::photoOptions()])
|
||||
->query(fn (Builder $query, array $data): Builder => match (true) {
|
||||
blank($data['value'] ?? null) => $query,
|
||||
$data['value'] === 'all_year' => $query->where(fn (Builder $query) => $query->whereNull('appearance_ids')->orWhereJsonLength('appearance_ids', 0)),
|
||||
default => $query->whereJsonContains('appearance_ids', (int) $data['value']),
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
@@ -53,6 +73,22 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('seasons')
|
||||
->label('Zeigen in …')
|
||||
->icon('heroicon-o-sun')
|
||||
->schema([
|
||||
Select::make('appearance_ids')
|
||||
->label('Zeigen in')
|
||||
->multiple()
|
||||
->options(fn (): array => Appearance::photoOptions())
|
||||
->placeholder('ganzjährig')
|
||||
->helperText('Leer = ganzjährig. Ersetzt die bisherige Zuordnung der ausgewählten Fotos.'),
|
||||
])
|
||||
->action(function (Collection $records, array $data): void {
|
||||
$records->each(fn (Photo $photo) => $photo->update(['appearance_ids' => PhotoForm::appearanceIds($data['appearance_ids'] ?? [])]));
|
||||
})
|
||||
->authorizeIndividualRecords('update')
|
||||
->deselectRecordsAfterCompletion(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user