toArray(); return $form ->schema([ Section::make('Page Information') ->description('Add a new page') ->schema([ TextInput::make('title')->label('Page Title') ->required() ->live(1) ->columnSpanFull() ->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state))), TextInput::make('slug')->required()->columnSpan(3), Select::make('is_published') ->options([ 0 => 'Draft', 1 => 'Published' ]) ->default(1) ->required() ->searchable() ->label('Status') ->columnSpan(1), RichEditor::make('content')->label('Page Content')->required()->columnSpanFull(), FileUpload::make('page_image') ->label('Custom Image (Optional)') ->directory('media/pages') ->columnSpanFull() ->preserveFilenames() ->image() ->maxSize(2048), ]) ->columns(4), Section::make('Customize Page') ->description('Modifiy Page SEO and Meta Information') ->schema([ KeyValue::make('meta') ->label('Meta (Optional)') ->keyPlaceholder('Name') ->valuePlaceholder('Content') ->reorderable(), Select::make('parent')->options($pages)->label('Parents (Optional)'), Textarea::make('custom_header')->rows(6)->label('Custom Header (Optional)'), ]), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('title')->searchable(), TextColumn::make('slug'), IconColumn::make('is_published')->label('Published')->boolean(), TextColumn::make('created_at') ->label('Created At'), ]) ->defaultSort('created_at', 'desc') ->filters([ Tables\Filters\SelectFilter::make('is_published') ->label('Status') ->options([ 0 => 'Draft', 1 => 'Published', ]), ]) ->actions([ Tables\Actions\ViewAction::make(), Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), Tables\Actions\Action::make('togglePublished') ->label('Toggle Published') ->icon('heroicon-o-eye') ->action(function (\App\Models\Page $record) { $record->update(['is_published' => !$record->is_published]); }), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListPages::route('/'), 'create' => Pages\CreatePage::route('/create'), 'edit' => Pages\EditPage::route('/{record}/edit'), ]; } }