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.'); }), Action::make('version') ->label('Fassung veröffentlichen') ->visible(fn (): bool => ContentElementResource::editor()) ->schema([ Select::make('element_id')->label('Element')->options(fn (): array => CatalogOptions::elements())->required(), Textarea::make('body')->label('Text'), FileUpload::make('incoming')->label('Datei')->disk('cms_incoming')->directory('inhalte'), TextInput::make('change_note')->label('Änderungsnotiz'), ]) ->action(function (array $data): void { $this->report(function () use ($data): void { $metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : []; app(ContentService::class)->publishElementVersion( ContentElement::query()->findOrFail($data['element_id']), $data['body'] ?? null, $metadata, $data['change_note'] ?? null, ); }, 'Die Fassung ist gespeichert.'); }), ]; } }