This package is currently under development. Use at your own risk!
Via Composer
$ composer require atthakasem/laravel-json-menu-
Create a menu file in
resouces/menus/main.jsoncontaining an array of pages. A page can be represented by a string or an object.[ "News", "About us", { "name": "Home", "url": "/" }, { "name": "Career", "children": ["Our perks", "Vacancies"] }, { "name": "Our partner", "url": "https://www.google.com", "external": true }, "Contact us", { "name": "Data protection", "class": "my-css-class another-one" } ] -
Use the menu in your blade file via
@menu()or@menu('main'). The resulting output will be:<ul> <li><a href="http://localhost/news">News</a></li> <li><a href="http://localhost/about-us">About us</a></li> <li><a href="http://localhost" class="active">Home</a></li> <li> <a href="http://localhost/career">Career</a> <ul> <li><a href="http://localhost/career/our-perks">Our perks</a></li> <li><a href="http://localhost/career/vacancies">Vacancies</a></li> </ul> </li> <li><a href="https://www.google.com" target="_blank">Our partner</a></li> <li><a href="http://localhost/contact-us">Contact us</a></li> <li><a href="http://localhost/data-protection" class="my-css-class another-one">Data protection</a></li> </ul>
These JSON properties can be used. When using object notation, only "name" is mandatory.
| Property | Description | Value type | Default |
|---|---|---|---|
| name | Displayed name of the menu item | string | N/A |
| url | Relative URL to desired page | string | Illuminate\Support\Str::slug($name) |
| route | Named route to desired page | string | null |
| external | Open link in a new tab | boolean | false |
| children | Subpages of the menu item | array | [] |
| class | CSS classes of the menu item | string | null |
$ php artisan vendor:publish --provider="Atthakasem\LaravelJsonMenu\LaravelJsonMenuServiceProvider"will create a config file config/laravel-json-menu.php where you can change the path.
Please see the changelog for more information on what has changed recently.
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
Please see the license file for more information.