schema([ Forms\Components\Card::make() ->schema([ TextInput::make('title') ->required() ->maxLength(255) ->reactive() ->afterStateUpdated(fn (string $operation, $state, Forms\Set $set) => $operation === 'create' ? $set('slug', Str::slug($state)) : null), TextInput::make('slug') ->required() ->maxLength(255) ->disabled() ->dehydrated() ->unique(News::class, 'slug', ignoreRecord: true), FileUpload::make('image') ->label('Image 1100x660') ->image() ->directory('news') ->nullable() ->columnSpanFull(), Select::make('author_id') ->relationship('author', 'name') ->searchable() ->preload() ->required(), RichEditor::make('content') ->required() ->columnSpanFull(), DateTimePicker::make('published_at') ->required() ->default(now()), ]) ->columns(2), ]); } public static function table(Table $table): Table { return $table ->columns([ ImageColumn::make('image') ->square() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('title') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('slug') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('author.name') ->label('Author Name') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('published_at') ->dateTime() ->sortable(), Tables\Columns\TextColumn::make('created_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ CommentsRelationManager::class, ]; } public static function getPages(): array { return [ 'index' => Pages\ManageNews::route('/'), 'create' => Pages\CreateNews::route('/create'), 'edit' => Pages\EditNews::route('/{record}/edit'), ]; } }