columns(3) ->components([ Section::make('Beitrag') ->columnSpan(2) ->schema([ TextInput::make('title')->label('Titel')->required()->maxLength(160), Textarea::make('teaser') ->label('Kurztext') ->helperText('Erscheint in Listen und auf der Startseite. 1–2 Sätze.') ->rows(2) ->maxLength(300), RichEditor::make('body') ->label('Text') ->toolbarButtons([ ['bold', 'italic', 'underline', 'link'], ['h2', 'h3'], ['bulletList', 'orderedList', 'blockquote'], ['attachFiles', 'table'], ['undo', 'redo'], ]) ->fileAttachmentsDisk('uploads') ->fileAttachmentsDirectory('news/inline') ->fileAttachmentsVisibility('public') ->fileAttachmentsAcceptedFileTypes(['image/jpeg', 'image/png', 'image/webp']) ->fileAttachmentsMaxSize(8 * 1024), ]), Section::make('Veröffentlichung') ->columnSpan(1) ->schema([ Select::make('category_id') ->label('Kategorie') ->relationship('category', 'name') ->preload() ->searchable(), DateTimePicker::make('published_at') ->label('Veröffentlichen am') ->helperText('Leer lassen = Entwurf. Ein Datum in der Zukunft plant den Beitrag.') ->seconds(false) ->native(false) ->displayFormat('d.m.Y H:i'), Toggle::make('is_featured') ->label('Auf der Startseite hervorheben') ->helperText('Hervorgehobene Beiträge mit Titelbild erscheinen groß im Slider.'), FileUpload::make('cover_path') ->label('Titelbild') ->helperText('Querformat, mindestens 1600 × 900 Pixel.') ->image() ->disk('uploads') ->directory('news') ->visibility('public') ->imageAspectRatio('16:9') ->automaticallyCropImagesToAspectRatio() ->maxSize(10 * 1024), ]), ]); } public static function table(Table $table): Table { return $table ->defaultSort('created_at', 'desc') ->columns([ ImageColumn::make('cover_path')->label('')->disk('uploads')->width(80)->height(45), TextColumn::make('title')->label('Titel')->searchable()->limit(60)->weight('medium'), TextColumn::make('category.name')->label('Kategorie')->badge()->color('gray'), TextColumn::make('status') ->label('Status') ->badge() ->state(fn (NewsPost $record) => match (true) { $record->published_at === null => 'Entwurf', $record->published_at->isFuture() => 'Geplant', default => 'Veröffentlicht', }) ->color(fn (string $state) => match ($state) { 'Veröffentlicht' => 'success', 'Geplant' => 'warning', default => 'gray', }), IconColumn::make('is_featured')->label('Hervorgehoben')->boolean()->trueIcon(Heroicon::Star)->falseIcon(false)->trueColor('warning'), TextColumn::make('published_at')->label('Veröffentlicht')->dateTime('d.m.Y H:i')->sortable(), ]) ->filters([ SelectFilter::make('category_id')->label('Kategorie')->relationship('category', 'name'), ]) ->recordActions([ Action::make('view') ->label('Ansehen') ->icon(Heroicon::OutlinedEye) ->url(fn (NewsPost $record) => route('news.show', $record)) ->openUrlInNewTab() ->visible(fn (NewsPost $record) => $record->isPublished()), EditAction::make(), DeleteAction::make(), ]); } public static function getPages(): array { return [ 'index' => ListNewsPosts::route('/'), 'create' => CreateNewsPost::route('/neu'), 'edit' => EditNewsPost::route('/{record}/bearbeiten'), ]; } }