PHP code example of shuvroroy / nova-dynamic-views

1. Go to this page and download the library: Download shuvroroy/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/ */

    

shuvroroy / nova-dynamic-views example snippets

 
use ShuvroRoy\NovaDynamicViews\NovaDynamicViews;

...

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

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

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

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

    //...
}

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

use ShuvroRoy\NovaDynamicViews\CustomComponents;

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

    /**
     * Using the `custom-index-toolbar` placeholder component
     * 
     * @return CustomComponents
     */
    public function customIndexToolbarComponents(): CustomComponents
    {
        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 CustomComponents
     */
    public function customDetailHeaderComponents(): CustomComponents
    {
        $model = $this->model()->query()->where('id', request('id'))->first();
        
        return CustomComponents::make()
           ->addItem('my-other-component', [
                'id' => $model->id,
                'name' => $model->name    
           ]);
    }
}