defaultSort(static::getRecordRouteKeyName(), 'desc') ->filters(static::getFilters()) ->filtersFormMaxHeight('400px') ->actions(static::getActions()) ->bulkActions(static::getBulkActions()) ->headerActions(static::getHeaderActions()) ->recordUrl(fn (Model $record): string => static::getUrl('view', ['record' => $record])) ->paginated([10, 25, 50, 100, 'all']) ->defaultPaginationPageOption(25); } /** * The panel for timestamp fields. * * @return array */ public static function timestamps(): array { return [ TextEntry::make(BaseModel::ATTRIBUTE_CREATED_AT) ->label(__('filament.fields.base.created_at')) ->dateTime(), TextEntry::make(BaseModel::ATTRIBUTE_UPDATED_AT) ->label(__('filament.fields.base.updated_at')) ->dateTime(), TextEntry::make(BaseModel::ATTRIBUTE_DELETED_AT) ->label(__('filament.fields.base.deleted_at')) ->dateTime() ->placeholder('-'), ]; } /** * Get the filters available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getFilters(): array { return [ TrashedFilter::make(), DateFilter::make(BaseModel::ATTRIBUTE_CREATED_AT) ->labels(__('filament.filters.base.created_at_from'), __('filament.filters.base.created_at_to')), DateFilter::make(BaseModel::ATTRIBUTE_UPDATED_AT) ->labels(__('filament.filters.base.updated_at_from'), __('filament.filters.base.updated_at_to')), DateFilter::make(BaseModel::ATTRIBUTE_DELETED_AT) ->labels(__('filament.filters.base.deleted_at_from'), __('filament.filters.base.deleted_at_to')), ]; } /** * Get the actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getActions(): array { return [ ViewAction::make(), EditAction::make(), ActionGroup::make([ DetachAction::make(), DeleteAction::make(), ForceDeleteAction::make(), ]) ->icon('heroicon-o-trash') ->color('danger'), RestoreAction::make(), ]; } /** * Get the bulk actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getBulkActions(): array { return [ BulkActionGroup::make([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), ]), ]; } /** * Get the header actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getHeaderActions(): array { return []; } /** * Get the eloquent query for the resource. * * @return Builder * * @noinspection PhpMissingParentCallCommonInspection */ public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } /** * Get the base relationships available for all resources. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getBaseRelations(): array { return [ ActionLogRelationManager::class, ]; } /** * Get the generic slug (URI key) for the resource. * * @return string * * @noinspection PhpMissingParentCallCommonInspection */ public static function getSlug(): string { return 'resources/' . static::getRecordSlug(); } /** * Get the slug (URI key) for the resource. * * @return string */ abstract public static function getRecordSlug(): string; }