Skip to content

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 MenuNova, /nova/admin-menu
Reorder sections and the entries inside themdragdrag
Move an entry into another sectiona Section select on the entrydrag it there
Nest entries — an entry under another—drag it inside
Rename a section or an entrythe Section / Label fieldthe label field
Set an icon on an entrya Heroicon name, heroicon-o-squares-2x2a Heroicon name, squares-2x2
Hide a section or an entrythe Hidden switchhide
Restrict who sees itWho sees it: permissions, any one of them is enoughthe 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 buildResetreset

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 ​

WhatWhere
Editstable menu_overrides (the site's table prefix in front): a row per entry, per admin (filament, nova)
ReadingKitloom\AdminMenu\Contracts\MenuOverrides — all($admin), find($admin, $key), as MenuOverride value objects: parent, sort, label, icon, hidden, permissions, custom
WritingKitloom\AdminMenu\MenuEditor — replace, put, forget, clear, with the acting user; visibleTo($permissions, $user)
Configurationconfig/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 of MenuOverrides; ArrayMenuOverrides is there for tests and a menu described in configuration.
  • The screens: kitloom-admin-menu.filament.register and kitloom-admin-menu.nova.register turn 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) and navigation_sort move the screen. An application with a Nova::mainMenu callback of its own calls AdminMenu::sort($menu, $request) from inside it and lists AdminMenuTool among its tools.

Tests ​

From the application that installs the package: php vendor/bin/phpunit --testsuite AdminMenu.

kitloom — modules and themes for Laravel.
Pricing · Services · License · Refunds · Privacy · Community · [email protected]