Files
laraundfelix/app/Filament/Resources/RightsProfiles/Pages/ListRightsProfiles.php
LarsandCursor d6ff881e4e
Deploy Test / test (push) Successful in 18s
Deploy Test / deploy (push) Successful in 22s
Mache die Inhaltsverwaltung fuer die Redaktion bedienbar
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 08:59:30 +01:00

62 lines
2.4 KiB
PHP

<?php
namespace App\Filament\Resources\RightsProfiles\Pages;
use App\Domain\Catalog\OfferService;
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Support\Htmlable;
class ListRightsProfiles extends ListRecords
{
use ReportsDomainRules;
protected static string $resource = RightsProfileResource::class;
public function getSubheading(): string|Htmlable|null
{
return 'Ein Rechteprofil beschreibt den Zweck und die erlaubten Handlungen. Es wird nicht verkauft; ein Angebot verbindet es mit Artikeln.';
}
protected function getHeaderActions(): array
{
return [
Action::make('create')->label('Rechteprofil anlegen')->schema([
TextInput::make('name')->label('Name')->required(),
Select::make('purpose')->label('Zweck')->options([
'ehrenamtlich' => 'Ehrenamtlich',
'kommerziell' => 'Kommerziell',
'institutionell' => 'Institutionell',
])->required(),
CheckboxList::make('capabilities')->label('Fähigkeiten')->options([
'film:streamen' => 'Film ansehen',
'film:laden' => 'Film herunterladen',
'audio:streamen' => 'Hörstück ansehen',
'document:ansehen' => 'Dokument ansehen',
'document:laden' => 'Dokument herunterladen',
'pdf:ansehen' => 'PDF ansehen',
'pdf:laden' => 'PDF herunterladen',
'text:ansehen' => 'Text ansehen',
'bild:ansehen' => 'Bild ansehen',
])->required(),
])->action(function (array $data): void {
$this->report(function () use ($data): void {
$capabilities = [];
foreach ($data['capabilities'] as $entry) {
[$class, $action] = explode(':', $entry, 2);
$capabilities[$class][] = $action;
}
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
}, 'Das Rechteprofil ist angelegt.');
}),
];
}
}