PHP code example of digital-creative / resource-navigation-tab

1. Go to this page and download the library: Download digital-creative/resource-navigation-tab 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/ */

    

digital-creative / resource-navigation-tab example snippets


use DigitalCreative\ResourceNavigationTab\HasResourceNavigationTabTrait;
use DigitalCreative\ResourceNavigationTab\ResourceNavigationField;

class ExampleNovaResource extends Resource {
 
    use HasResourceNavigationTabTrait;

    public function fields(NovaRequest $request): array
    {
        return [
            ResourceNavigationField::make('Information')
                ->fields([
                    Text::make('Name'),
                    Text::make('Age'),
                    HasMany::make('Hobbies'),
                ]),
            ResourceNavigationField::make('Activities')->fields([ ... ]),
            ResourceNavigationField::make('Social Interactions')->fields([ ... ]),
            ResourceNavigationField::make('Settings')->fields([ ... ]),
        ];
    }

}

use DigitalCreative\ResourceNavigationTab\HasResourceNavigationTabTrait;
use DigitalCreative\ResourceNavigationTab\ResourceNavigationField;
use DigitalCreative\ResourceNavigationTab\CardMode;

class ExampleNovaResource extends Resource {

    use HasResourceNavigationTabTrait;
 
    public function fields(NovaRequest $request): array
    {
        return [
            ResourceNavigationField::make('Information'), // show all the available cards by default
            ResourceNavigationField::make('Activities')->withCards([ DailySalesCard::class, ClientProfileCard::class ]), // only show these cards when this tab is active
            ResourceNavigationField::make('Settings')->withoutCards(), // hide all cards when this tab is active
        ];
    }

    public function cards(NovaRequest $request): array
    {
        return [
            new ClientPerformanceCard(),
            new DailySalesCard(),
            new ClientProfileCard()
        ];
    }

}