PHP code example of notebrainslab / filament-menu-manager
1. Go to this page and download the library: Download notebrainslab/filament-menu-manager 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/ */
notebrainslab / filament-menu-manager example snippets
use NoteBrainsLab\FilamentMenuManager\FilamentMenuManagerPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(
FilamentMenuManagerPlugin::make()
->locations([
'primary' => 'Primary',
'footer' => 'Footer',
])
);
}
FilamentMenuManagerPlugin::make()
->locations([
'primary' => 'Primary',
'footer' => 'Footer',
])
->modelSources([
\App\Models\Post::class,
\App\Models\Page::class,
])
->navigationGroup('Content')
->navigationIcon('heroicon-o-bars-3')
->navigationSort(10)
->navigationLabel('Menus')
->authentication(function () {
return auth()->user()->can('View:MenuManagerPage');
// Expected boolean value: true or false
// Based on your permission matrix
}),
use NoteBrainsLab\FilamentMenuManager\Concerns\HasMenuItems;
class Post extends Model
{
use HasMenuItems;
// Optional: override the defaults
public function getMenuLabel(): string
{
return $this->title;
}
public function getMenuUrl(): string
{
return route('posts.show', $this);
}
public function getMenuTarget(): string
{
return '_self';
}
public function getMenuIcon(): ?string
{
return 'heroicon-o-document';
}
}