Appearance
Admin Menu
Arrange the admin menu from the admin itself: reorder, move, rename, hide, set icons, restrict who sees what, and add sections and links of your own.
kitloom/admin-menu · admins: kitloom/admin-menu-filament, kitloom/admin-menu-nova
The admin menu is not fixed by the packages that build it: an administrator arranges it from the admin itself, and the edits apply on top of whatever the application and the modules put there — in Filament and in Nova alike, from one table.
What an administrator can do
| Filament, Tools → Admin Menu | Nova, /nova/admin-menu | |
|---|---|---|
| Reorder sections and the entries inside them | drag | drag |
| Move an entry into another section | a Section select on the entry | drag it there |
| Nest entries — an entry under another | — | drag it inside |
| Rename a section or an entry | the Section / Label field | the label field |
| Set an icon on an entry | a Heroicon name, heroicon-o-squares-2x2 | a Heroicon name, squares-2x2 |
| Hide a section or an entry | the Hidden switch | hide |
| Restrict who sees it | Who sees it: permissions, any one of them is enough | the same |
| Add your own sections, groups and links — to a page of the admin, or any URL | — | Add section, Add link; your own ones can be deleted again |
| Reset to what the packages build | Reset | reset |
Everything else keeps working as before: an entry you hide is only out of the menu, the page behind it still opens by its address and still asks its own permission. An entry restricted to permissions is shown to a user who holds any one of them; a section hidden or restricted takes its entries with it.
What nobody has placed yet — the section of a module installed later — goes after the placed entries (kitloom-admin-menu.default_sort) until someone drags it where it belongs. Both screens are for those who may manage_options.
The edits are per admin: the Filament menu and the Nova menu are arranged separately, in the same table, so a site that runs both keeps two layouts.
What is inside
| What | Where |
|---|---|
| Edits | table menu_overrides (the site's table prefix in front): a row per entry, per admin (filament, nova) |
| Reading | Kitloom\AdminMenu\Contracts\MenuOverrides — all($admin), find($admin, $key), as MenuOverride value objects: parent, sort, label, icon, hidden, permissions, custom |
| Writing | Kitloom\AdminMenu\MenuEditor — replace, put, forget, clear, with the acting user; visibleTo($permissions, $user) |
| Configuration | config/kitloom-admin-menu.php |
A site arranges its menu once, in a migration, the way the Nova skeleton puts the sidebar in WordPress order — Dashboard, Posts, Media, Pages, Comments, Appearance, Modules, Users, Tools, Settings — and administrators change it from there:
php
use Kitloom\AdminMenu\Contracts\MenuOverrides;
use Kitloom\AdminMenu\MenuEditor;
// A migration arranging the menu — the system, nobody is asked.
app(MenuEditor::class)->put(MenuOverrides::NOVA, 'App\Nova\Tools\Posts', ['sort' => 1400]);
// A user: `manage_options` is asked of them, AuthorizationException otherwise.
app(MenuEditor::class)->replace(MenuOverrides::FILAMENT, $overrides, $request->user());
// Who sees an entry restricted to permissions: any one of them is enough.
app(MenuEditor::class)->visibleTo(['edit_posts', 'manage_options'], $user);An entry is named the way its admin recognises it across requests: Filament by group:{label} and item:{URL}, Nova by the class behind the entry, then menu_path:{path}, then menu_label:{label}; menu_custom:{id} is an entry the admin added themselves (custom holds its type and path).
Coming from the earlier packages
The migration creates menu_overrides and copies the rows of filament_menu_overrides and nova_menu_overrides when those tables are there; the old tables are left for the site to drop.
What the application overrides
- Storage:
kitloom-admin-menu.repository, an implementation ofMenuOverrides;ArrayMenuOverridesis there for tests and a menu described in configuration. - The screens:
kitloom-admin-menu.filament.registerandkitloom-admin-menu.nova.registerturn them off (php artisan vendor:publish --tag=kitloom-admin-menu-config); the saved menu still applies. In Filament,kitloom-admin-menu.filament.navigation_group(Tools) andnavigation_sortmove the screen. An application with aNova::mainMenucallback of its own callsAdminMenu::sort($menu, $request)from inside it and listsAdminMenuToolamong its tools.
Tests
From the application that installs the package: php vendor/bin/phpunit --testsuite AdminMenu.