PHP code example of hoceineel / filament-sidebar-editor
1. Go to this page and download the library: Download hoceineel/filament-sidebar-editor 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/ */
hoceineel / filament-sidebar-editor example snippets
use HoceineEl\SidebarEditor\SidebarEditorPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(SidebarEditorPlugin::make());
}
use App\Models\User;
use HoceineEl\SidebarEditor\SidebarEditorPlugin;
SidebarEditorPlugin::make()
->storeOnTenant('navigation')
->authorize(fn (): bool => auth()->user()?->can('manage-sidebar') ?? false)
->slug('menu')
->navigationGroup('settings')
->navigationSort(45)
->pinnedItems(['dashboard', 'billing'])
->fixedMainGroup();
use Filament\Panel;
use HoceineEl\SidebarEditor\Contracts\LayoutStore;
class SettingsStore implements LayoutStore
{
public function get(Panel $panel): ?array
{
return settings("sidebar.{$panel->getId()}");
}
public function put(Panel $panel, ?array $groups): void
{
settings()->set("sidebar.{$panel->getId()}", $groups);
}
}
SidebarEditorPlugin::make()->store(SettingsStore::class);