laravellaravel-nova

How to show markdown field on index in Laravel nova?


I have a nova model named "Note" with the following field method

public function fields(Request $request)
{
    return [
        ID::make()->sortable()->hideFromIndex(),

        Markdown::make('Note')
            ->rules('required', 'string'),
    ];
}

In the index page I can only see ID of table. Any idea on how to display Markdown field in index?


Solution

  • You have to set the attribute showOnIndex to true.

    public function fields(Request $request)
    {
        $noteField = Markdown::make('Note');
        $noteField->showOnIndex = true;
    
        return [
            ID::make()->sortable()->hideFromIndex(),
    
            $noteField->rules('required', 'string'),
        ];
    }