*/ public static $model = BannerModel::class; /** * The single value that should be used to represent the resource when being displayed. * * @var string */ public static $title = 'id'; /** * The columns that should be searched. * * @var array */ public static $search = [ 'name', ]; /** * The relationships that should be eager loaded on index queries. * * @var array */ public static $with = ['media']; /** * Get the displayable label of the resource. */ public static function label(): string { return __('Banners'); } /** * Get the displayable singular label of the resource. */ public static function singularLabel(): string { return __('Banner'); } /** * Get the fields displayed by the resource. */ public function fields(NovaRequest $request): array { return [ new Panel(__('Basic information'), [ ID::make()->sortable(), Images::make(__('Image'), 'main') ->conversionOnIndexView('thumb200x200') ->rules('required') ->required(), Select::make(__('App'), 'app') ->displayUsingLabels() ->searchable() ->options(OS::apps()) ->default(OS::WEBSITE), Select::make(__('Place'), 'place') ->displayUsingLabels() ->searchable() ->options(BannerModel::places()) ->rules('required'), Text::make(__('Name'), 'title') ->translatable() ->rules('nullable', 'string', 'max:255'), URL::make(__('Link'), 'link') ->displayUsing(fn () => $this->link) ->rules('nullable', 'string', 'max:2048') ->hideFromIndex(), NovaSwitcher::make(__('Visible'), 'is_visible') ->default(true), ]), new Panel(__('Additional information'), [ Select::make(__('Resource type to attach'), 'resource_type') ->displayUsingLabels() ->searchable() ->options(BannerModel::attachableResources()) ->rules('nullable') ->onlyOnForms(), Select::make(__('Resource to attach'), 'resource_id') ->displayUsingLabels() ->searchable() ->rules('nullable') ->dependsOn(['resource_type'], function ($field, $request, $formData) { if ($formData->resource_type) { $field->options(BannerRepository::getNovaResource($formData->resource_type))->rules('required'); } }) ->onlyOnForms(), Text::make( __('Attached resource'), fn () => view('vendor.nova.resources.banner.resource-type', ['resource' => $this])->render() )->asHtml()->hideFromIndex(), Text::make(__('Note'), 'description') ->translatable() ->rules('nullable', 'string', 'max:255') ->hideFromIndex(), ]), ]; } /** * Get the cards available for the request. */ public function cards(NovaRequest $request): array { return []; } /** * Get the filters available for the resource. */ public function filters(NovaRequest $request): array { return [ new VisableFilter, new AppTypeFilter, ]; } /** * Get the lenses available for the resource. */ public function lenses(NovaRequest $request): array { return []; } /** * Get the actions available for the resource. */ public function actions(NovaRequest $request): array { return []; } }