Inhaltsverwaltung: Bilder, Webseiten-Texte, Ausstattung, FAQ, Hinweis-Banner

- Bilder mit automatischen WebP-Webgrößen (640/1280/2048 px), Sortierung per Drag & Drop, Mehrfach-Upload, Import-Befehl photos:import
- Webseiten-Texte als feste, bearbeitbare Bausteine (config/content.php), Rich-Text bereinigt ausgegeben
- Ausstattung und FAQ aus der bisherigen Webseite übernommen
- Rolle Inhalte hat Zugriff auf alle Webseiten-Bereiche

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 10:19:51 +02:00
1 parent 27ea12901e
commit bb7eb62782
53 files changed
+1963 -1

No files matched your search

@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Filament\Resources\Photos\PhotoResource;
use Filament\Resources\Pages\CreateRecord;
class CreatePhoto extends CreateRecord
{
protected static string $resource = PhotoResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Filament\Resources\Photos\PhotoResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditPhoto extends EditRecord
{
protected static string $resource = PhotoResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,66 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Enums\PhotoCategory;
use App\Filament\Resources\Photos\PhotoResource;
use App\Models\Photo;
use App\Models\Property;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
class ListPhotos extends ListRecords
{
protected static string $resource = PhotoResource::class;
protected function getHeaderActions(): array
{
return [
Action::make('bulkUpload')
->label('Mehrere Bilder hochladen')
->icon(Heroicon::OutlinedArrowUpTray)
->authorize('create', Photo::class)
->modalDescription('Die Bildbeschreibung wird aus dem Dateinamen vorbelegt – bitte danach kurz anpassen.')
->schema([
FileUpload::make('files')
->label('Bilder')
->multiple()
->image()
->maxSize(25 * 1024)
->storeFiles(false)
->required(),
Select::make('category')
->label('Kategorie')
->options(PhotoCategory::class)
->default(PhotoCategory::Apartment)
->required(),
])
->action(function (array $data): void {
$propertyId = Property::query()->value('id');
$nextSort = (int) Photo::max('sort_order');
/** @var TemporaryUploadedFile $file */
foreach ($data['files'] as $file) {
$photo = Photo::create([
'property_id' => $data['category'] === PhotoCategory::Area->value ? null : $propertyId,
'category' => $data['category'],
'alt_text' => str(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME))->replace(['_', '-'], ' ')->squish()->ucfirst()->toString(),
'sort_order' => ++$nextSort,
]);
$photo->addMedia($file->getRealPath())
->usingFileName($file->getClientOriginalName())
->toMediaCollection(Photo::COLLECTION);
}
Notification::make()->title(count($data['files']).' Bilder hochgeladen')->success()->send();
}),
CreateAction::make()->label('Einzelnes Bild'),
];
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Resources\Photos;
use App\Filament\Resources\Photos\Pages\CreatePhoto;
use App\Filament\Resources\Photos\Pages\EditPhoto;
use App\Filament\Resources\Photos\Pages\ListPhotos;
use App\Filament\Resources\Photos\Schemas\PhotoForm;
use App\Filament\Resources\Photos\Tables\PhotosTable;
use App\Models\Photo;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class PhotoResource extends Resource
{
protected static ?string $model = Photo::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPhoto;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Bild';
protected static ?string $pluralModelLabel = 'Bilder';
protected static ?int $navigationSort = 1;
public static function form(Schema $schema): Schema
{
return PhotoForm::configure($schema);
}
public static function table(Table $table): Table
{
return PhotosTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListPhotos::route('/'),
'create' => CreatePhoto::route('/create'),
'edit' => EditPhoto::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,53 @@
<?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)
->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),
]);
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Filament\Resources\Photos\Tables;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
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;
class PhotosTable
{
public static function configure(Table $table): Table
{
return $table
->reorderable('sort_order')
->defaultSort('sort_order')
->contentGrid(['md' => 3, 'xl' => 4])
->paginated([24, 48, 'all'])
->columns([
Stack::make([
SpatieMediaLibraryImageColumn::make('image')
->collection(Photo::COLLECTION)
->conversion('sm')
->imageHeight(180)
->extraImgAttributes(['class' => 'w-full object-cover rounded-lg']),
TextColumn::make('alt_text')
->weight('medium')
->searchable(),
TextColumn::make('category')
->badge(),
IconColumn::make('is_published')
->boolean()
->trueIcon('heroicon-o-eye')
->falseIcon('heroicon-o-eye-slash'),
])->space(2),
])
->filters([
SelectFilter::make('category')
->label('Kategorie')
->options(PhotoCategory::class),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}