phpcollective/menumaker

An elegant multi level menu system for the Laravel framework.

v1.0.15 2024-03-07 06:35 UTC

README

Latest Version on Packagist Software License Quality Score Total Downloads

Menu Maker is a nice and convenient way to manage your menu items for the Laravel framework. You can create multi level menu items for different sections of your site like Left Menu, Top Menu etc with it. It will provide the authorization of menu as well.

Structure

Directory structure of the project are as follows:

config/
public/        
resources/        
src/

Install

You may use Composer to install the package into your Laravel project:

$ composer require phpcollective/menumaker
Laravel 5.5+:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

PhpCollective\MenuMaker\MenuServiceProvider::class,

After installing Menu Maker, publish its assets using the menu:install Artisan command. It will publish all assets and configurations as well as run migrations related to menu maker.

$ php artisan menu:install

Add MenuMaker trait in User model.

<?php

namespace App;

use PhpCollective\MenuMaker\MenuMaker;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, MenuMaker;
    
    ...
}

At this point you're all good to go. See Uses for how to get started with the package.

Usage

Accessing Package

By default all routes are prefixed with /menu-maker.

  • Users: /menu-maker/users
  • Roles: /menu-maker/roles
  • Sections: /menu-maker/sections
  • Menus: /menu-maker/menus
  • Permissions: /menu-maker/permissions

You can change this prefix by editing path in config/menu.php.

'path' => 'menu-maker'

Middleware

Menu Maker uses menu for middleware.

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::middleware('menu')->group(function () {
    // Your routes will goes here
});

Credits

License

Laravel Menu Maker is open-sourced software licensed under the MIT license.