- Galerien sind nun eine Entität - es kann mehrere geben
- Neues Sparkbooth-Upload-Feature: Endpoint /api/sparkbooth/upload (Token-basiert pro Galerie), Controller Api/SparkboothUploadController, Migration 2026_01_21_000001_add_upload_fields_to_galleries_table.php mit Upload-Flags/Token/Expiry;
Galerie-Modell und Factory/Seeder entsprechend erweitert.
- Filament: Neue Setup-Seite SparkboothSetup (mit View) zur schnellen Galerie- und Token-Erstellung inkl. QR/Endpoint/Snippet;
Galerie-Link-Views nutzen jetzt simple-qrcode (Composer-Dependency hinzugefügt) und bieten PNG-Download.
- Galerie-Tabelle: Slug/Pfad-Spalten entfernt, Action „Link-Details“ mit Modal; Created-at-Spalte hinzugefügt.
- Zugriffshärtung: Galerie-IDs in API (ImageController, Download/Print) geprüft; GalleryAccess/Middleware + Gallery-Modell/Slug-UUID
eingeführt; GalleryAccess-Inertia-Seite.
- UI/UX: LoadingSpinner/StyledImageDisplay verbessert, Delete-Confirm, Übersetzungen ergänzt.
This commit is contained in:
86
app/Filament/Resources/Galleries/GalleryResource.php
Normal file
86
app/Filament/Resources/Galleries/GalleryResource.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries;
|
||||
|
||||
use App\Filament\Resources\Galleries\Pages\CreateGallery;
|
||||
use App\Filament\Resources\Galleries\Pages\EditGallery;
|
||||
use App\Filament\Resources\Galleries\Pages\ListGalleries;
|
||||
use App\Filament\Resources\Galleries\Schemas\GalleryForm;
|
||||
use App\Filament\Resources\Galleries\Tables\GalleriesTable;
|
||||
use App\Models\Gallery;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use UnitEnum;
|
||||
|
||||
class GalleryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Gallery::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static UnitEnum|string|null $navigationGroup = 'Content';
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return __('filament.navigation.groups.content');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return GalleryForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return GalleriesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListGalleries::route('/'),
|
||||
'create' => CreateGallery::route('/create'),
|
||||
'edit' => EditGallery::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data = self::mutatePassword($data);
|
||||
$data['slug'] = $data['slug'] ?: Str::uuid()->toString();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$data = self::mutatePassword($data);
|
||||
$data['slug'] = $data['slug'] ?: Str::uuid()->toString();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function mutatePassword(array $data): array
|
||||
{
|
||||
$password = $data['password'] ?? null;
|
||||
unset($data['password']);
|
||||
|
||||
if (! empty($password)) {
|
||||
$data['password_hash'] = Hash::make($password);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Galleries/Pages/CreateGallery.php
Normal file
11
app/Filament/Resources/Galleries/Pages/CreateGallery.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries\Pages;
|
||||
|
||||
use App\Filament\Resources\Galleries\GalleryResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateGallery extends CreateRecord
|
||||
{
|
||||
protected static string $resource = GalleryResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Galleries/Pages/EditGallery.php
Normal file
19
app/Filament/Resources/Galleries/Pages/EditGallery.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries\Pages;
|
||||
|
||||
use App\Filament\Resources\Galleries\GalleryResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditGallery extends EditRecord
|
||||
{
|
||||
protected static string $resource = GalleryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Galleries/Pages/ListGalleries.php
Normal file
19
app/Filament/Resources/Galleries/Pages/ListGalleries.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries\Pages;
|
||||
|
||||
use App\Filament\Resources\Galleries\GalleryResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListGalleries extends ListRecords
|
||||
{
|
||||
protected static string $resource = GalleryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
74
app/Filament/Resources/Galleries/Schemas/GalleryForm.php
Normal file
74
app/Filament/Resources/Galleries/Schemas/GalleryForm.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class GalleryForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Details')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->label('Slug')
|
||||
->disabled()
|
||||
->dehydrated(true)
|
||||
->helperText('Wird automatisch erzeugt'),
|
||||
TextInput::make('title')
|
||||
->label('Titel')
|
||||
->required(),
|
||||
TextInput::make('images_path')
|
||||
->label('Bilder-Pfad')
|
||||
->helperText('Relativer Pfad unter public/storage')
|
||||
->required(),
|
||||
Toggle::make('is_public')
|
||||
->label('Öffentlich')
|
||||
->default(true),
|
||||
Toggle::make('allow_ai_styles')
|
||||
->label('AI-Stile erlauben')
|
||||
->default(true),
|
||||
Toggle::make('allow_print')
|
||||
->label('Drucken erlauben')
|
||||
->default(true),
|
||||
Toggle::make('require_password')
|
||||
->label('Passwortschutz aktiv')
|
||||
->default(false),
|
||||
TextInput::make('password')
|
||||
->label('Neues Passwort')
|
||||
->password()
|
||||
->revealable()
|
||||
->dehydrated(false)
|
||||
->helperText('Leer lassen, um das bestehende Passwort zu behalten.'),
|
||||
DateTimePicker::make('expires_at')
|
||||
->label('Ablaufdatum')
|
||||
->native(false)
|
||||
->seconds(false),
|
||||
TextInput::make('access_duration_minutes')
|
||||
->label('Zugriffsdauer (Minuten)')
|
||||
->numeric()
|
||||
->minValue(1)
|
||||
->nullable()
|
||||
->helperText('Optional: Zeitfenster nach dem ersten Unlock.'),
|
||||
]),
|
||||
View::make('filament.components.gallery-link')
|
||||
->columnSpanFull()
|
||||
->visible(fn (?object $record) => (bool) $record?->id)
|
||||
->viewData(fn (?object $record) => [
|
||||
'url' => $record ? URL::route('gallery.show', $record) : null,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
63
app/Filament/Resources/Galleries/Tables/GalleriesTable.php
Normal file
63
app/Filament/Resources/Galleries/Tables/GalleriesTable.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Galleries\Tables;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class GalleriesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('Titel')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
IconColumn::make('allow_ai_styles')
|
||||
->label('AI-Stile')
|
||||
->boolean(),
|
||||
IconColumn::make('allow_print')
|
||||
->label('Drucken')
|
||||
->boolean(),
|
||||
IconColumn::make('require_password')
|
||||
->label('Passwort')
|
||||
->boolean(),
|
||||
TextColumn::make('expires_at')
|
||||
->label('Läuft ab')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Erstellt am')
|
||||
->dateTime('d.m.Y H:i')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
Action::make('link_details')
|
||||
->label('Link-Details')
|
||||
->icon('heroicon-o-link')
|
||||
->modalHeading('Link-Details')
|
||||
->modalContent(fn ($record) => view('filament.components.gallery-link-modal', [
|
||||
'record' => $record,
|
||||
'url' => route('gallery.show', $record),
|
||||
]))
|
||||
->modalSubmitAction(false)
|
||||
->modalCancelAction(false),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user