src/Resources/Post.php
/**
     * Get the fields displayed by the resource.
     */
Get the fields displayed by the resource.
Get the fields displayed by the resource .
public function fields(Request $request): array
    {
        $resources = config('nova-blog.resources');
        return [
            ID::make()->sortable(),
            BelongsTo::make(__('Category'), 'category', $resources['category'])
                ->sortable(),
            $this->makeTemplatesField()
                ->rules('required', 'string')
                ->displayUsingLabels()
                ->sortable(),
            new Panel(__('Content'), $this->makeContentFields()),
            new Panel(__('Search Optimization'), $this->makeSEOFields()),
            Boolean::make(__('Is Published'), 'is_published')
                ->hideWhenCreating()
                ->hideWhenUpdating(),
            DateTime::make(__('Published At'), 'published_at')
                ->help(__('A date when post will be available for viewing'))
                ->rules('nullable', 'date')
                ->hideFromIndex()
                ->hideFromDetail()
                ->firstDayOfWeek(1),
            DateTime::make(__('Created At'), 'created_at')
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            DateTime::make(__('Published At'), 'published_at')
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            DateTime::make(__('Updated At'), 'updated_at')
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            BelongsTo::make(__('Author'), 'author', $resources['user'])
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            BelongsToMany::make(__('Tags'), 'tags', $resources['tag']),
            HasMany::make(__('Comments'), 'comments', $resources['comment']),
        ];
    }
public function fields ( Request $ request ) : array { $ resources = config ( 'nova-blog.resources' ) ; return [ ID :: make ( ) -> sortable ( ) , BelongsTo :: make ( __ ( 'Category' ) , 'category' , $ resources [ 'category' ] ) -> sortable ( ) , $ this -> makeTemplatesField ( ) -> rules ( 'required' , 'string' ) -> displayUsingLabels ( ) -> sortable ( ) , new Panel ( __ ( 'Content' ) , $ this -> makeContentFields ( ) ) , new Panel ( __ ( 'Search Optimization' ) , $ this -> makeSEOFields ( ) ) , Boolean :: make ( __ ( 'Is Published' ) , 'is_published' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) , DateTime :: make ( __ ( 'Published At' ) , 'published_at' ) -> help ( __ ( 'A date when post will be available for viewing' ) ) -> rules ( 'nullable' , 'date' ) -> hideFromIndex ( ) -> hideFromDetail ( ) -> firstDayOfWeek ( 1 ) , DateTime :: make ( __ ( 'Created At' ) , 'created_at' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , DateTime :: make ( __ ( 'Published At' ) , 'published_at' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , DateTime :: make ( __ ( 'Updated At' ) , 'updated_at' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , BelongsTo :: make ( __ ( 'Author' ) , 'author' , $ resources [ 'user' ] ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , BelongsToMany :: make ( __ ( 'Tags' ) , 'tags' , $ resources [ 'tag' ] ) , HasMany :: make ( __ ( 'Comments' ) , 'comments' , $ resources [ 'comment' ] ) , ] ; }
Get the fields displayed by the resource.
Get the fields displayed by the resource .