Tip
Prefer to configure everything by hand? Publish the configuration with php artisan vendor:publish --tag=sidebar-config and set sidebar.sidebar.class to your sidebar class.
composer require wikigods/laravel-sidebar
The service provider Wikigods\Sidebar\SidebarServiceProvider is registered automatically with package discovery.
php artisan sidebar:install
The installer asks for the cache method, template, permission driver, sidebar class, target view, view data key and middleware alias. Accept the defaults to get:
app/Sidebars/AdminSidebar.php with a Dashboard item.config/sidebar.php pointing to that class.See sidebar:install for every option.
The rendered HTML is shared with the configured target view (admin.partials._sidebar by default) under the configured key (sidebar). In resources/views/admin/partials/_sidebar.blade.php:
{!! $sidebar !!}
The sidebar middleware builds the registered sidebars, so it must run on every route that renders the view:
use Illuminate\Support\Facades\Route;
Route::middleware(['auth', 'sidebar'])->group(function () {
// Routes that render the sidebar...
});
The alias is registered by the package; you don't need to add it to bootstrap/app.php.
Prefer to configure everything by hand? Publish the configuration with php artisan vendor:publish --tag=sidebar-config and set sidebar.sidebar.class to your sidebar class.