Organize your resource fields into tabs.
Organize your resource fields into tabs.
You can install the package via composer:
composer require digital-creative/resource-navigation-tab
First, import HasResourceNavigationTabTrait
trait into your resource and start grouping your fields with
the ResourceNavigationField
object:
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([ ... ]),
];
}
}
Once setup navigate to your resource detail view, and you should be presented with this card:
Every defined card will be shown on every tab by default, however you can choose which card you want to show when a
specific tab is selected:
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()
];
}
}
Please give a ⭐️ if this project helped you!
Help card
that comes with Nova.The MIT License (MIT). Please see License File for more information.