Introduced a two-tier media pipeline with dynamic disks, asset tracking, admin controls, and alerting around
upload/archival workflows.
- Added storage metadata + asset tables and models so every photo/variant knows where it lives
(database/migrations/2025_10_20_090000_create_media_storage_targets_table.php, database/ migrations/2025_10_20_090200_create_event_media_assets_table.php, app/Models/MediaStorageTarget.php:1, app/
Models/EventMediaAsset.php:1, app/Models/EventStorageAssignment.php:1, app/Models/Event.php:27).
- Rewired guest and tenant uploads to pick the event’s hot disk, persist EventMediaAsset records, compute
checksums, and clean up on delete (app/Http/Controllers/Api/EventPublicController.php:243, app/Http/
Controllers/Api/Tenant/PhotoController.php:25, app/Models/Photo.php:25).
- Implemented storage services, archival job scaffolding, monitoring config, and queue-failure notifications for upload issues (app/Services/Storage/EventStorageManager.php:16, app/Services/Storage/
StorageHealthService.php:9, app/Jobs/ArchiveEventMediaAssets.php:16, app/Providers/AppServiceProvider.php:39, app/Notifications/UploadPipelineFailed.php:8, config/storage-monitor.php:1).
- Seeded default hot/cold targets and exposed super-admin tooling via a Filament resource and capacity widget (database/seeders/MediaStorageTargetSeeder.php:13, database/seeders/DatabaseSeeder.php:17, app/Filament/Resources/MediaStorageTargetResource.php:1, app/Filament/Widgets/StorageCapacityWidget.php:12, app/Providers/Filament/SuperAdminPanelProvider.php:47).
- Dropped cron skeletons and artisan placeholders to schedule storage monitoring, archival dispatch, and upload queue health checks (cron/storage_monitor.sh, cron/archive_dispatcher.sh, cron/upload_queue_health.sh, routes/console.php:9).
264 lines
9.7 KiB
PHP
264 lines
9.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\PackageResource\Pages;
|
|
use App\Models\Package;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Forms\Components\CheckboxList;
|
|
use Filament\Forms\Components\MarkdownEditor;
|
|
use Filament\Forms\Components\Repeater;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Schemas\Components\Tabs as SchemaTabs;
|
|
use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Columns\BadgeColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use UnitEnum;
|
|
use BackedEnum;
|
|
|
|
class PackageResource extends Resource
|
|
{
|
|
protected static ?string $model = Package::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-cube';
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = null;
|
|
|
|
public static function getNavigationGroup(): UnitEnum|string|null
|
|
{
|
|
return __('admin.nav.platform_management');
|
|
}
|
|
|
|
protected static ?int $navigationSort = 5;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
$featureOptions = static::featureLabelMap();
|
|
|
|
return $schema->schema([
|
|
SchemaTabs::make('translations')
|
|
->columnSpanFull()
|
|
->tabs([
|
|
SchemaTab::make('Deutsch')
|
|
->schema([
|
|
TextInput::make('name_translations.de')
|
|
->label('Name (DE)')
|
|
->required()
|
|
->maxLength(255),
|
|
MarkdownEditor::make('description_translations.de')
|
|
->label('Beschreibung (DE)')
|
|
->required()
|
|
->columnSpanFull(),
|
|
]),
|
|
SchemaTab::make('English')
|
|
->schema([
|
|
TextInput::make('name_translations.en')
|
|
->label('Name (EN)')
|
|
->required()
|
|
->maxLength(255),
|
|
MarkdownEditor::make('description_translations.en')
|
|
->label('Description (EN)')
|
|
->required()
|
|
->columnSpanFull(),
|
|
]),
|
|
]),
|
|
Section::make('Allgemeine Einstellungen')
|
|
->columns(3)
|
|
->schema([
|
|
TextInput::make('slug')
|
|
->label('Slug')
|
|
->required()
|
|
->maxLength(191)
|
|
->unique(ignoreRecord: true),
|
|
Select::make('type')
|
|
->label('Paket-Typ')
|
|
->options([
|
|
'endcustomer' => 'Endkunde',
|
|
'reseller' => 'Reseller',
|
|
])
|
|
->required(),
|
|
TextInput::make('price')
|
|
->label('Preis')
|
|
->numeric()
|
|
->step(0.01)
|
|
->prefix('€')
|
|
->required(),
|
|
TextInput::make('max_photos')
|
|
->label('Max. Fotos')
|
|
->numeric()
|
|
->minValue(0)
|
|
->nullable(),
|
|
TextInput::make('max_guests')
|
|
->label('Max. Gäste')
|
|
->numeric()
|
|
->minValue(0)
|
|
->nullable(),
|
|
TextInput::make('gallery_days')
|
|
->label('Galeriedauer (Tage)')
|
|
->numeric()
|
|
->minValue(0)
|
|
->nullable(),
|
|
TextInput::make('max_tasks')
|
|
->label('Max. Fotoaufgaben')
|
|
->numeric()
|
|
->minValue(0)
|
|
->nullable(),
|
|
TextInput::make('max_events_per_year')
|
|
->label('Events pro Jahr')
|
|
->numeric()
|
|
->minValue(0)
|
|
->nullable()
|
|
->visible(fn ($get) => $get('type') === 'reseller'),
|
|
Toggle::make('watermark_allowed')
|
|
->label('Wasserzeichen erlaubt')
|
|
->default(true),
|
|
Toggle::make('branding_allowed')
|
|
->label('Eigenes Branding erlaubt')
|
|
->default(false),
|
|
]),
|
|
Section::make('Features & Kennzahlen')
|
|
->columns(1)
|
|
->schema([
|
|
CheckboxList::make('features')
|
|
->label('Aktive Features')
|
|
->options($featureOptions)
|
|
->columns(2)
|
|
->default([]),
|
|
Repeater::make('description_table')
|
|
->label('Kenndaten')
|
|
->schema([
|
|
TextInput::make('title')
|
|
->label('Titel')
|
|
->maxLength(255),
|
|
TextInput::make('value')
|
|
->label('Wert / Beschreibung')
|
|
->maxLength(255),
|
|
])
|
|
->addActionLabel('Eintrag hinzufügen')
|
|
->reorderable()
|
|
->columnSpanFull()
|
|
->default([]),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function formatFeaturesForDisplay(mixed $features): string
|
|
{
|
|
if (is_string($features)) {
|
|
$decoded = json_decode($features, true);
|
|
if (json_last_error() === JSON_ERROR_NONE) {
|
|
$features = $decoded;
|
|
}
|
|
}
|
|
|
|
if (! is_array($features)) {
|
|
return '';
|
|
}
|
|
|
|
$labels = static::featureLabelMap();
|
|
|
|
if (array_is_list($features)) {
|
|
return collect($features)
|
|
->filter(fn ($value) => is_string($value) && $value !== '')
|
|
->map(fn ($value) => $labels[$value] ?? $value)
|
|
->implode(', ');
|
|
}
|
|
|
|
return collect($features)
|
|
->filter(fn ($value) => (bool) $value)
|
|
->keys()
|
|
->map(fn ($value) => $labels[$value] ?? $value)
|
|
->implode(', ');
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('name_translations.de')
|
|
->label('Name (DE)')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('name_translations.en')
|
|
->label('Name (EN)')
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
BadgeColumn::make('type')
|
|
->label('Typ')
|
|
->colors([
|
|
'info' => 'endcustomer',
|
|
'warning' => 'reseller',
|
|
]),
|
|
TextColumn::make('price')
|
|
->label('Preis')
|
|
->money('EUR')
|
|
->sortable(),
|
|
TextColumn::make('max_photos')
|
|
->label('Fotos')
|
|
->sortable(),
|
|
TextColumn::make('max_guests')
|
|
->label('Gäste')
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('features')
|
|
->label('Features')
|
|
->wrap()
|
|
->formatStateUsing(fn ($state) => static::formatFeaturesForDisplay($state)),
|
|
])
|
|
->filters([
|
|
Tables\Filters\SelectFilter::make('type')
|
|
->label('Typ')
|
|
->options([
|
|
'endcustomer' => 'Endkunde',
|
|
'reseller' => 'Reseller',
|
|
]),
|
|
])
|
|
->actions([
|
|
ViewAction::make(),
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListPackages::route('/'),
|
|
'create' => Pages\CreatePackage::route('/create'),
|
|
'edit' => Pages\EditPackage::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
protected static function featureLabelMap(): array
|
|
{
|
|
return [
|
|
'basic_uploads' => 'Basis-Uploads',
|
|
'limited_sharing' => 'Begrenztes Teilen',
|
|
'unlimited_sharing' => 'Unbegrenztes Teilen',
|
|
'no_watermark' => 'Kein Wasserzeichen',
|
|
'custom_branding' => 'Eigenes Branding',
|
|
'custom_tasks' => 'Eigene Aufgaben',
|
|
'reseller_dashboard' => 'Reseller-Dashboard',
|
|
'advanced_analytics' => 'Erweiterte Analytics',
|
|
'advanced_reporting' => 'Erweiterte Reports',
|
|
'live_slideshow' => 'Live-Slideshow',
|
|
'priority_support' => 'Priorisierter Support',
|
|
];
|
|
}
|
|
}
|