PHP code example of bernhardh / nova-dynamic-views

1. Go to this page and download the library: Download bernhardh/nova-dynamic-views library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bernhardh / nova-dynamic-views example snippets

 
use Bernhardh\NovaDynamicViews\NovaDynamicViews;

...

public function tools() {
    return [
        new NovaDynamicViews()
    ];
}

public function customIndexToolbarComponents()
{
    return CustomComponents::make()
       ->addItem('my-index-toolbar-btn');
}

public function customIndexToolbarComponents()
{
    return CustomComponents::make()
       ->addItem('my-index-toolbar-btn', [
           'label' => 'My label'
       ]); 
}

public function customDetailToolbarComponents() 
{
    $model = $this->model()->query()->where('id', request('id'))->first();

    //...
}

public function customIndexToolbarComponents()
{
    return CustomComponents::make('flex w-full justify-end items-center mx-3')
       ->addItem('my-index-toolbar-btn'); 
}

class Resource extends \Laravel\Nova\Resource {
    ...

    /**
     * Using the `custom-index-toolbar` placeholder component
     * 
     * @return array[]
     */
    public function customIndexToolbarComponents()
    {
        return CustomComponents::make('flex w-full justify-end items-center mx-3')
            ->addItem('my-index-toolbar-btn', [
                'title' => 'My first btn'
            ])
            ->addItem('my-index-toolbar-btn', [
                'title' => 'My second btn'
            ]);
    }

    /**
     * Using the `custom-detail-header` placeholder component
     * 
     * @return array[]
     */
    public function customDetailHeaderComponents()
    {
        $model = $this->model()->query()->where('id', request('id'))->first();
        
        return CustomComponents::make()
           ->addItem('my-other-component', [
                'id' => $model->id,
                'name' => $model->name    
           ]);
    }
}