Dieselbe Liste trägt die öffentliche Seite. Medien bleiben privat, Seiten können mehreren Säulen zugeordnet sein. Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.8 KiB
PHP
79 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Pillars;
|
|
|
|
use App\Domain\Catalog\Pillar;
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use App\Filament\Resources\Pillars\Pages\EditPillar;
|
|
use App\Filament\Resources\Pillars\Pages\ListPillars;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Auth\Access\Response;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PillarResource extends Resource
|
|
{
|
|
protected static ?string $model = Pillar::class;
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
|
|
|
protected static ?string $navigationLabel = 'Fachliche Säulen';
|
|
|
|
protected static ?string $modelLabel = 'Fachliche Säule';
|
|
|
|
protected static ?string $pluralModelLabel = 'Fachliche Säulen';
|
|
|
|
protected static ?string $recordTitleAttribute = 'name';
|
|
|
|
protected static ?string $slug = 'saeulen';
|
|
|
|
protected static ?int $navigationSort = 5;
|
|
|
|
public static function canViewAny(): bool
|
|
{
|
|
return ContentElementResource::editor();
|
|
}
|
|
|
|
public static function getEditAuthorizationResponse(Model $record): Response
|
|
{
|
|
return ContentElementResource::editor() ? Response::allow() : Response::deny();
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
TextInput::make('name')->label('Name')->required(),
|
|
TextInput::make('slug')->label('Öffentliche Adresse')->required()
|
|
->helperText('Ergibt die Seite /themen/adresse. Eine Änderung verschiebt die öffentliche Adresse.'),
|
|
Textarea::make('public_summary')->label('Text für die Website')->rows(5)
|
|
->helperText('Dieser Text erscheint auf der Website. Die zugeordneten Medien bleiben privat.'),
|
|
TextInput::make('sort_order')->label('Reihenfolge')->numeric()->minValue(0)->required()->default(0),
|
|
Toggle::make('published')->label('Auf der Website veröffentlichen'),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table->columns([
|
|
TextColumn::make('name')->label('Name')->searchable(),
|
|
TextColumn::make('public_state')->label('Website')->state(
|
|
fn (Pillar $record): string => $record->published_at === null ? 'intern' : 'veröffentlicht'
|
|
),
|
|
TextColumn::make('elements_count')->counts('elements')->label('Medien'),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListPillars::route('/'),
|
|
'edit' => EditPillar::route('/{record}'),
|
|
];
|
|
}
|
|
}
|