PHP code example of jrbconsulting / filament-menu-builder
1. Go to this page and download the library: Download jrbconsulting/filament-menu-builder 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/ */
jrbconsulting / filament-menu-builder example snippets
use Vendor\FilamentMenuBuilder\Resources\MenuResource;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->resources([
MenuResource::class,
// ...
]);
}
// Get all active menus as tree
$menuTree = \Vendor\FilamentMenuBuilder\Models\Menu::getTree();
// Get root menus only
$rootMenus = \Vendor\FilamentMenuBuilder\Models\Menu::root()->active()->get();
// Get children of specific parent
$submenus = \Vendor\FilamentMenuBuilder\Models\Menu::where('parent_id', $parentId)->get();
// Get menu with depth calculation
$menu = \Vendor\FilamentMenuBuilder\Models\Menu::find(1);
$depth = $menu->calculateDepth(); // Number of ancestors
return [
// Model class used for menus
'model' => \Vendor\FilamentMenuBuilder\Models\Menu::class,
// Database table name
'table_name' => 'menus',
// Enable multi-tenant mode
'tenant_aware' => false,
// Enable menu tree caching
'cache_enabled' => true,
// Cache duration in seconds
'cache_duration' => 3600,
];