*/ public static $model = AttributeModel::class; /** * The single value that should be used to represent the resource when being displayed. * * @var string */ public static $title = 'name'; /** * The columns that should be searched. * * @var array */ public static $search = [ 'name', ]; /** * Get the displayable label of the resource. */ public static function label(): string { return __('Attributes'); } /** * Get the displayable singular label of the resource. */ public static function singularLabel(): string { return __('Attribute'); } /** * Get the fields displayed by the resource. */ public function fields(NovaRequest $request): array { return [ ID::make()->sortable(), Text::make(__('Name'), 'name') ->rules('required', 'string') ->translatable(), Select::make(__('Type'), 'type') ->displayUsingLabels() ->searchable() ->default(AttributeModel::typesFields()['text']) ->options(AttributeModel::typesFields()) ->rules('required'), Trix::make(__('Description'), 'description') ->translatable(), NovaSwitcher::make(__('Is enabled'), 'is_visible') ->default(true) ->canSeeWhen('systemUser', $this), NovaSwitcher::make(__('Is required'), 'is_required') ->default(true) ->canSeeWhen('systemUser', $this), NovaSwitcher::make(__('Is searchable'), 'is_searchable') ->default(false) ->canSeeWhen('systemUser', $this), NovaSwitcher::make(__('Is filterable'), 'is_filterable') ->default(false) ->canSeeWhen('systemUser', $this), Boolean::make(__('Is enabled'), 'is_visible') ->canSeeWhen('vendor', $this), Boolean::make(__('Is required'), 'is_required') ->canSeeWhen('vendor', $this), Boolean::make(__('Is searchable'), 'is_searchable') ->canSeeWhen('vendor', $this), Boolean::make(__('Is filterable'), 'is_filterable') ->canSeeWhen('vendor', $this), AttachMany::make(__('Categories'), 'categories', Category::class), Multiselect::make(__('Categories'), 'categories')->belongsToMany(Category::class) ->onlyOnDetail(), HasMany::make(__('Attribute values'), 'values', AttributeValue::class) ->hideFromDetail(function (NovaRequest $request, $resource) { return $this->type !== 'select'; }), ]; } /** * Get the cards available for the request. * * @return array */ public function cards(NovaRequest $request) { return []; } /** * Get the filters available for the resource. * * @return array */ public function filters(NovaRequest $request) { return []; } /** * Get the lenses available for the resource. * * @return array */ public function lenses(NovaRequest $request) { return []; } /** * Get the actions available for the resource. * * @return array */ public function actions(NovaRequest $request) { return []; } }