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:
1 parent
27ea12901e
commit
bb7eb62782
53 files changed
+1963
-1
No files matched your search
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user