Pharaonic
Loading...

Getting Started

Menus

# Why Menus?

Menus is a package that provides a quick and easy way to create menus items for Laravel.

This package depends on Translatable.

# Installation

Install the latest version using Composer.

1composer require pharaonic/laravel-menus
2php artisan migrate

# Creating

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// OR
13$item = Menu::set('header', [
14 'en' => [
15 'title' => 'Pharaonic'
16 ],
17 'ar' => [
18 'title' => 'فرعوني'
19 ]
20], 'https://pharaonic.io');

# Scopes

To retrieve a single menu, just you have to it like this.

1use Pharaonic\Laravel\Menus\Models\Menu;
2 
3// 1. Section
4// 1. Locale [string] (OPTIONAL)
5$items = Menu::section('header')->get();

# Directives

This is the easiest way you can use to include the menu into your Blade file.

1@menu('header')

# Publish views, migrations

You can publish the views and migrations

1php artisan vendor:publish --tag=laravel-menus

# Contributors

MoamenEltouny
11 Contributions