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).
279 lines
11 KiB
PHP
279 lines
11 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Blog\Resources;
|
|
|
|
use App\Filament\Blog\Resources\PostResource\Pages;
|
|
use App\Filament\Blog\Traits\HasContentEditor;
|
|
use App\Models\BlogPost;
|
|
use App\Models\BlogCategory;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\DateTimePicker;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\MarkdownEditor;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Components\Utilities\Set;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Str;
|
|
use Filament\Schemas\Components\Tabs as SchemaTabs;
|
|
use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|
class PostResource extends Resource
|
|
{
|
|
use HasContentEditor;
|
|
|
|
protected static ?string $model = BlogPost::class;
|
|
|
|
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document-text';
|
|
|
|
protected static ?string $navigationLabel = 'Beiträge';
|
|
|
|
protected static ?string $pluralLabel = 'Beiträge';
|
|
|
|
protected static ?string $modelLabel = 'Beitrag';
|
|
|
|
public static function getNavigationGroup(): string
|
|
{
|
|
return 'Content & Bibliothek';
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->schema([
|
|
SchemaTabs::make('Übersetzungen')
|
|
->tabs([
|
|
SchemaTab::make('Deutsch')
|
|
->schema([
|
|
TextInput::make('title.de')
|
|
->label('Titel')
|
|
->required()
|
|
->maxLength(255)
|
|
->live()
|
|
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state) {
|
|
if (($get('slug') ?? '') !== Str::slug($state)) {
|
|
return;
|
|
}
|
|
|
|
$set('slug', Str::slug($state));
|
|
}),
|
|
MarkdownEditor::make('content.de')
|
|
->label('Inhalt')
|
|
->required()
|
|
->columnSpanFull(),
|
|
TextInput::make('excerpt.de')
|
|
->label('Auszug')
|
|
->maxLength(255),
|
|
TextInput::make('meta_title.de')
|
|
->label('Meta-Titel')
|
|
->maxLength(255),
|
|
Textarea::make('meta_description.de')
|
|
->label('Meta-Beschreibung')
|
|
->maxLength(65535)
|
|
->columnSpanFull(),
|
|
])
|
|
->columns(2),
|
|
SchemaTab::make('Englisch')
|
|
->schema([
|
|
TextInput::make('title.en')
|
|
->label('Titel')
|
|
->maxLength(255),
|
|
MarkdownEditor::make('content.en')
|
|
->label('Inhalt')
|
|
->columnSpanFull(),
|
|
TextInput::make('excerpt.en')
|
|
->label('Auszug')
|
|
->maxLength(255),
|
|
TextInput::make('meta_title.en')
|
|
->label('Meta-Titel')
|
|
->maxLength(255),
|
|
Textarea::make('meta_description.en')
|
|
->label('Meta-Beschreibung')
|
|
->maxLength(65535)
|
|
->columnSpanFull(),
|
|
])
|
|
->columns(2),
|
|
]),
|
|
TextInput::make('slug')
|
|
->label('Slug')
|
|
->required()
|
|
->unique(BlogPost::class, 'slug', ignoreRecord: true)
|
|
->maxLength(255),
|
|
Section::make('Bild und Kategorie')
|
|
->schema([
|
|
FileUpload::make('featured_image')
|
|
->label('Featured Image')
|
|
->image()
|
|
->directory('blog')
|
|
->visibility('public'),
|
|
Select::make('blog_category_id')
|
|
->label('Kategorie')
|
|
->options(fn () => BlogCategory::query()
|
|
->orderBy('slug')
|
|
->get()
|
|
->mapWithKeys(fn (BlogCategory $category) => [
|
|
$category->getKey() => $category->name['de'] ?? $category->name['en'] ?? $category->slug,
|
|
])->toArray())
|
|
->searchable()
|
|
->required()
|
|
->preload()
|
|
->createOptionForm([
|
|
TextInput::make('name_de')
|
|
->label('Name (DE)')
|
|
->required()
|
|
->maxLength(255)
|
|
->afterStateUpdated(fn (Set $set, $state) => $set('name_en', $state)),
|
|
TextInput::make('name_en')
|
|
->label('Name (EN)')
|
|
->maxLength(255),
|
|
TextInput::make('slug')
|
|
->label('Slug')
|
|
->required()
|
|
->unique(\App\Models\BlogCategory::class, 'slug', ignoreRecord: true)
|
|
->maxLength(255),
|
|
])
|
|
->createOptionUsing(function (array $data) {
|
|
$nameDe = $data['name_de'] ?? null;
|
|
$nameEn = $data['name_en'] ?? null;
|
|
|
|
$category = BlogCategory::create([
|
|
'slug' => $data['slug'],
|
|
'is_visible' => true,
|
|
'name' => [
|
|
'de' => $nameDe ?: ($nameEn ?: $data['slug']),
|
|
'en' => $nameEn ?: ($nameDe ?: $data['slug']),
|
|
],
|
|
'description' => null,
|
|
]);
|
|
|
|
return $category->getKey();
|
|
}),
|
|
])
|
|
->columns(2),
|
|
Section::make('Veröffentlichung')
|
|
->schema([
|
|
Toggle::make('is_published')
|
|
->label('Veröffentlicht'),
|
|
DateTimePicker::make('published_at')
|
|
->label('Veröffentlicht am')
|
|
->displayFormat('Y-m-d H:i:s')
|
|
->default(now()),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function mutateFormDataBeforeCreate(array $data): array
|
|
{
|
|
return $data;
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('title')
|
|
->label('Titel (DE)')
|
|
->getStateUsing(fn ($record) => $record->getTranslation('title', 'de'))
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('category_label')
|
|
->label('Kategorie')
|
|
->badge()
|
|
->getStateUsing(function ($record) {
|
|
$raw = $record->category?->name ?? null;
|
|
|
|
if (is_string($raw) && $raw !== '') {
|
|
$decoded = json_decode($raw, true);
|
|
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
|
$raw = $decoded;
|
|
}
|
|
}
|
|
|
|
if (is_array($raw)) {
|
|
return $raw['de'] ?? $raw['en'] ?? '—';
|
|
}
|
|
|
|
if (is_string($raw) && $raw !== '') {
|
|
return $raw;
|
|
}
|
|
|
|
return '—';
|
|
})
|
|
->color('primary'),
|
|
IconColumn::make('is_published')
|
|
->label('Veröffentlicht')
|
|
->boolean()
|
|
->trueIcon('heroicon-o-check-circle')
|
|
->falseIcon('heroicon-o-x-circle'),
|
|
TextColumn::make('published_at')
|
|
->label('Veröffentlicht am')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('created_at')
|
|
->label('Erstellt am')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->filters([
|
|
TernaryFilter::make('is_published')
|
|
->label('Veröffentlicht'),
|
|
])
|
|
->actions([
|
|
ViewAction::make(),
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListPosts::route('/'),
|
|
'create' => Pages\CreatePost::route('/create'),
|
|
'view' => Pages\ViewPost::route('/{record}'),
|
|
'edit' => Pages\EditPost::route('/{record}/edit'),
|
|
];
|
|
}
|
|
|
|
public static function getEloquentQuery(): Builder
|
|
{
|
|
return parent::getEloquentQuery()
|
|
->withoutGlobalScopes([
|
|
SoftDeletingScope::class,
|
|
]);
|
|
}
|
|
}
|