label('Säule anlegen') ->modalHeading('Neue fachliche Säule') ->modalDescription('Der Name genügt. Website-Text, Adresse und Veröffentlichung legst du danach fest.') ->modalSubmitActionLabel('Säule anlegen') ->visible(fn (): bool => ContentElementResource::editor()) ->schema([ TextInput::make('name')->label('Name')->required(), ]) ->action(function (array $data): void { $pillar = null; $this->report(function () use ($data, &$pillar): void { $pillar = app(PillarService::class)->create($data['name']); }, 'Die Säule ist angelegt.'); if ($pillar !== null) { $this->redirect(PillarResource::getUrl('edit', ['record' => $pillar])); } }), ]; } protected function catalogRows(): array { $rows = []; foreach (Pillar::query()->withCount('elements')->orderBy('sort_order')->orderBy('name')->get() as $pillar) { $public = $pillar->published_at !== null; $url = PillarResource::getUrl('edit', ['record' => $pillar]); $rows[] = [ 'schluessel' => 's'.$pillar->id, 'titel' => $pillar->name, 'meta' => 'Fachliche Säule'.(filled($pillar->slug) ? ' · /themen/'.$pillar->slug : ''), 'text' => (string) ($pillar->public_summary ?? ''), 'symbol' => 'modul', 'url' => $url, 'chips' => [ $public ? ['label' => 'Auf der Website veröffentlicht', 'ton' => 'gut'] : ['label' => 'Intern', 'ton' => 'leise'], ['label' => $pillar->elements_count === 1 ? '1 Medium' : $pillar->elements_count.' Medien', 'ton' => 'neutral'], ], 'zustand' => [$public ? 'oeffentlich' : 'intern'], 'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']], ]; } return $rows; } protected function zustandOptionen(): array { return ['alle' => 'Jeder Zustand', 'oeffentlich' => 'Auf der Website veröffentlicht', 'intern' => 'Intern']; } protected function einheit(): array { return ['Fachliche Säule', 'Fachliche Säulen']; } protected function leer(): array { return ['titel' => 'Noch keine Säulen', 'text' => 'Mit „Säule anlegen“ oben entsteht die erste Säule.']; } }