*/ public static string $model = \App\Models\Config::class; /** * The columns that should be searched. * * @var array */ public static $search = ['key']; /** * The logical group associated with the resource. * * @var string */ public static $group = 'Other'; /** * Get the displayable label of the resource. */ public static function label(): string { return 'Settings'; } /** * Get the displayable singular label of the resource. */ public static function singularLabel(): string { return 'Setting'; } /** * Resolves the display title from the config class title or falls back to the raw key. */ public function title(): string { return $this->getConfigClass()?->title ?? $this->resource->key; } /** * Get the fields displayed by the resource. * * @return array */ public function fields(NovaRequest $request): array { return array_merge( [ Text::make('Name', 'key') ->resolveUsing(fn ($value) => $this->getConfigClass()?->title ?? $value) ->exceptOnForms(), Text::make('Description', 'key') ->resolveUsing(fn () => $this->getConfigClass()?->description ?? '') ->exceptOnForms(), ], array_map( fn ($field) => $field->hideFromIndex(), $this->getConfigClass()?->getNovaFields() ?? [] ), [ DateTime::make('Created At')->exceptOnForms()->hideFromIndex()->sortable()->filterable(), DateTime::make('Updated At')->exceptOnForms()->hideFromIndex()->sortable()->filterable(), ], ); } /** * Get the cards available for the request. * * @return array */ public function cards(NovaRequest $request): array { return []; } /** * Get the filters available for the resource. * * @return array */ public function filters(NovaRequest $request): array { return []; } /** * Get the lenses available for the resource. * * @return array */ public function lenses(NovaRequest $request): array { return []; } /** * Get the actions available for the resource. * * @return array */ public function actions(NovaRequest $request): array { return []; } /** * Resolves the config class instance for this resource's key via the Config service. */ private function getConfigClass(): ?object { $key = $this->resource?->key; if ($key === null) { return null; } return app(\App\Services\Config::class)->getConfigClassForGroup($key); } }