57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\ContentElements\Pages;
|
|
|
|
use App\Domain\Catalog\ContentService;
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
|
|
class ListContentElements extends ListRecords
|
|
{
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = ContentElementResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Das Material selbst: Film, Text, PDF. Kompositionen und Lizenzartikel verweisen darauf.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')
|
|
->label('Element anlegen')
|
|
->visible(fn (): bool => ContentElementResource::editor())
|
|
->schema([
|
|
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
|
Select::make('kind')->label('Art')->options([
|
|
'film' => 'Film',
|
|
'audio' => 'Audio',
|
|
'bild' => 'Bild',
|
|
'pdf' => 'PDF',
|
|
'text' => 'Text',
|
|
'aufgabe' => 'Aufgabe',
|
|
])->required(),
|
|
Select::make('output_class')->label('Ausgabeklasse')->options([
|
|
'film' => 'Film',
|
|
'audio' => 'Audio',
|
|
'bild' => 'Bild',
|
|
'pdf' => 'PDF',
|
|
'text' => 'Text',
|
|
])->required(),
|
|
])
|
|
->action(function (array $data): void {
|
|
$this->report(function () use ($data): void {
|
|
app(ContentService::class)->createElement($data['kind'], $data['output_class'], $data['working_title']);
|
|
}, 'Das Inhaltselement ist angelegt.');
|
|
}),
|
|
];
|
|
}
|
|
}
|