Menus is a package that provides a quick and easy way to create menus items for Laravel.
This package depends on Translatable.
Install the latest version using Composer.
1composer require pharaonic/laravel-menus2php artisan migrate
This is how you can create a new menu item.
1use Pharaonic\Laravel\Menus\Models\Menu; 2 3// 1. Section 4// 2. Title OR array of localized data 5// 3. URL 6// 4. Parent ID [ingeter] (OPTIONAL) 7// 4. Sort [integer] (OPTIONAL) 8// 5. Visible [boolean] (OPTIONAL) 9// 6. Locale [string] (OPTIONAL)10$item = Menu::set('header', 'Pharaonic', 'https://pharaonic.io'); 11 12// OR13$item = Menu::set('header', [ 14 'en' => [15 'title' => 'Pharaonic'16 ],17 'ar' => [18 'title' => 'فرعوني'19 ]20], 'https://pharaonic.io');
To retrieve a single menu, just you have to it like this.
1use Pharaonic\Laravel\Menus\Models\Menu;2 3// 1. Section4// 1. Locale [string] (OPTIONAL)5$items = Menu::section('header')->get();
This is the easiest way you can use to include the menu into your Blade file.
1@menu('header')
You can publish the views and migrations
1php artisan vendor:publish --tag=laravel-menus