src/Resources/Comment.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(__('Post'), 'post', $resources['post'])
                ->sortable(),
            Text::make(__('Content'), 'content')
                ->hideFromDetail()
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->displayUsing(function () {
                    return implode(' ', array_slice(mb_split('\s+', strip_tags($this->content)), 0, 5)) . '...';
                }),
            $this->makeEditorField(__('Content'), 'content')
                ->rules('required', 'string:4000'),
            DateTime::make(__('Created At'), 'created_at')
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            DateTime::make(__('Updated At'), 'updated_at')
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
            BelongsTo::make(__('Author'), 'author', $resources['user'])
                ->hideWhenCreating()
                ->hideWhenUpdating()
                ->sortable(),
        ];
    }
public function fields ( Request $ request ) : array { $ resources = config ( 'nova-blog.resources' ) ; return [ ID :: make ( ) -> sortable ( ) , BelongsTo :: make ( __ ( 'Post' ) , 'post' , $ resources [ 'post' ] ) -> sortable ( ) , Text :: make ( __ ( 'Content' ) , 'content' ) -> hideFromDetail ( ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> displayUsing ( function ( ) { return implode ( ' ' , array_slice ( mb_split ( '\s+' , strip_tags ( $ this -> content ) ) , 0 , 5 ) ) . '...' ; } ) , $ this -> makeEditorField ( __ ( 'Content' ) , 'content' ) -> rules ( 'required' , 'string:4000' ) , DateTime :: make ( __ ( 'Created At' ) , 'created_at' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , DateTime :: make ( __ ( 'Updated At' ) , 'updated_at' ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , BelongsTo :: make ( __ ( 'Author' ) , 'author' , $ resources [ 'user' ] ) -> hideWhenCreating ( ) -> hideWhenUpdating ( ) -> sortable ( ) , ] ; }
Get the fields displayed by the resource.
Get the fields displayed by the resource .