Introduction

wikigods/laravel-sidebar builds, authorizes, caches and renders grouped navigation menus for Laravel applications.

You describe the menu once, in a plain PHP class:

use Wikigods\Sidebar\Badge;
use Wikigods\Sidebar\Group;
use Wikigods\Sidebar\Item;

$this->menu->group('Administration', function (Group $group) {
    $group->item('Users', function (Item $item) {
        $item->route('admin.users.index');
        $item->icon('fa fa-users');
        $item->badge(fn (Badge $badge) => $badge->setValue(User::count()));
        $item->authorizePermission('users.view');
    });
});

The package takes care of the rest:

  • Ordering of groups and items by weight, nested items and active state from the current URL.
  • Authorization with booleans or permission names (Laravel Gate / Spatie, Sentinel or your own resolver).
  • Caching of the built menu, shared or per user.
  • Rendering with the AdminLTE 2, AdminLTE 3 or AdminLV (Bootstrap 5) templates, or your own published views.
  • An installer, php artisan sidebar:install, that generates the sidebar class and the configuration.

Origin

This package continues Laravel Sidebar by Maatwebsite.nl under the Wikigods\Sidebar namespace. Applications using maatwebsite/laravel-sidebar can follow the upgrade guide.