getKeyName(); } /** * Get the title attribute for the resource. * * @return string * * @noinspection PhpMissingParentCallCommonInspection */ public static function getRecordTitleAttribute(): string { return (new static::$model)->getKeyName(); } /** * The index page of the resource. * * @param Table $table * @return Table * * @noinspection PhpMissingParentCallCommonInspection */ public static function table(Table $table): Table { return $table ->striped() ->defaultSort(fn (Table $table) => $table->hasSearch() ? null : static::getRecordRouteKeyName(), fn (Table $table) => $table->hasSearch() ? null : 'desc') ->filters(static::getFilters()) ->filtersFormMaxHeight('400px') ->actions(static::getActions()) ->bulkActions(static::getBulkActions()) ->headerActions(static::getTableActions()) ->recordUrl(fn (Model $record): string => static::getUrl('view', ['record' => $record])) ->paginated([10, 25, 50, 100, 'all']) ->defaultPaginationPageOption(25) ->extremePaginationLinks() ->deferLoading(!app()->runningUnitTests()); } /** * 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) ->label(__('filament.fields.base.created_at')), DateFilter::make(BaseModel::ATTRIBUTE_UPDATED_AT) ->label(__('filament.fields.base.updated_at')), DateFilter::make(BaseModel::ATTRIBUTE_DELETED_AT) ->label(__('filament.fields.base.deleted_at')), ]; } /** * 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(__('filament-icons.actions.base.group_delete')) ->color('danger'), RestoreAction::make(), ]; } /** * Get the bulk actions available for the resource. * * @param array|null $actionsIncludedInGroup * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getBulkActions(?array $actionsIncludedInGroup = []): array { return [ BulkActionGroup::make([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), ...$actionsIncludedInGroup, ]) ->authorize('forcedeleteany', static::getModel()), ]; } /** * Get the table actions available for the resource. * * @return array * * @noinspection PhpMissingParentCallCommonInspection */ public static function getTableActions(): array { return []; } /** * Get the eloquent query for the resource. * * @return Builder */ public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, WithoutInsertSongScope::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; }