*/ public static $model = ChannelModel::class; /** * The relationships that should be eager loaded on index queries. * * @var array */ public static $with = ['media', 'user']; /** * 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 __('Channels'); } /** * Get the displayable singular label of the resource. */ public static function singularLabel(): string { return __('Channel'); } /** * Fields for index */ public function fieldsForIndex(): array { return ChannelFieldsForIndex::make(); } /** * Get the fields displayed by the resource. */ public function fields(NovaRequest $request): array { return [ ID::make()->sortable(), Images::make(__('Image'), 'uploads') ->conversionOnIndexView('thumb400x400') ->rules('required') ->required(), Text::make(__('Name'), 'name') ->rules(['required', 'string', 'max:255']), Text::make(__('Description'), 'description') ->rules(['nullable', 'string', 'max:255']), URL::make('URL'), Hidden::make('is_default')->default(true), Hidden::make('timezone')->default('Asia/Ashgabat'), DateTime::make(__('Created at'), 'created_at') ->default(now()) ->displayUsing(fn ($value) => $value->format('H:i, d.m.Y')) ->exceptOnForms() ->sortable(), BelongsTo::make(__('User'), 'user', UserSearchResource::class) ->searchable() ->withSubtitles() ->readonly(fn () => $this->id === tmpostChannel()->id) ->fillUsing(function ($request, $model, $attribute, $requestAttribute) { $model->channelables_type = User::class; $model->channelables_id = $request->input('user'); }), NovaSwitcher::make(__('Active'), 'is_visible') ->default(true), MorphMany::make(__('Products'), 'products', Product::class), ]; } /** * 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 []; } }