Download the PHP package sagsoz06/laravel-menus without Composer
On this page you can find all versions of the php package sagsoz06/laravel-menus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-menus
Laravel Menus
nwidart/laravel-menus
is a laravel package which created to manage menus. It has a feature called presenters which enables easy styling and custom structure of menu rendering.
This package is a re-published, re-organised and maintained version of pingpong/menus, which isn't maintained anymore. This package is used in AsgardCMS.
With one big added bonus that the original package didn't have: tests.
- Installation
- Creating A Menu
- Menu Item
- Menu Dropdown
- Menu Dropdown Milti Level
- Menu Divider
- Dropdown Header
- Ordering Menu Item
- Make Lots of Menu
- Menu Presenter
- The Available Presenter
- Make A Custom Presenter
- Register A New Menu Style
- View Presenter
- The Available View Presenter
- Rendering Menu
- Menu Inheritance
- Menu Instance
- Finding Menu Item
- Modifying Menu
Installation
You can install the through composer command line.
After the package installed, add a new service provider to the providers
array in config/app.php
file.
Add new alias for Menu
facade to the aliases
array at the same file.
Then, publish package's assets by running:
Creating A Menu
You can define your menus in app/Support/menus.php
file. That file will loaded automatically by this package.
To create a menu, simply call the create
method from Menu
facade. The first parameter is the menu name and the second parameter is callback for defining menu items.
Menu Item
As explained before, we can defining menu item in the callback by accessing $menu
variable, which the variable is instance of Nwidart\Menus\MenuBuilder
class.
To defining a plain URL, you can use ->url()
method.
If you have named route, you define the menu item by calling ->route()
method.
You can also defining the menu item via array by calling ->add()
method.
Menu Dropdown
To create a dropdown menu, you can call to ->dropdown()
method and passing the first parameter by title of dropdown and the second parameter by closure callback that retrieve $sub
variable. The $sub
variable is the the instance of Nwidart\Menus\MenuItem
class.
Menu Dropdown Multi Level
You can also create a dropdown inside dropdown by using ->dropdown()
method. This will allow to to create a multilevel menu items.
Menu Divider
You may also define a divider for each menu item. You can divide between menu item by using ->divider()
method.
Dropdown Header
You may also add a dropdown header for the specified menu item by using ->header()
method.
Ordering Menu Item
You may order the menu by specify order
parameter.
You may also set the order value by calling ->order
method.
By default ordering feature is disabled. You can enable the ordering
feature in your config file. Just update value of ordering
config to true
and now your menu will ordered by order
key.
You may also enable or disable menu ordering for each menu via ->enableOrdering
and ->disableOrdering
method.
Make many of menus
You can also create a set of menus with different name and menu items.
Menu Presenter
This package includes some presenter classes that are used for converting menus to html. By default the generated menu style is bootstrap navbar
. But, there are also several different menu styles.
You can apply the menu style via ->style()
method.
Or you can set which presenter to present the menu style via ->setPresenter()
method.
You can also set which style of presenter when you rendering a menu.
The List of Available Menu Presenter Class
Name | Presenter Class |
---|---|
navbar |
Nwidart\Menus\Presenters\Bootstrap\NavbarPresenter |
navbar-right |
Nwidart\Menus\Presenters\Bootstrap\NavbarRightPresenter |
nav-pills |
Nwidart\Menus\Presenters\Bootstrap\NavPillsPresenter |
nav-tab |
Nwidart\Menus\Presenters\Bootstrap\NavTabPresenter |
sidebar |
Nwidart\Menus\Presenters\Bootstrap\SidebarMenuPresenter |
navmenu |
Nwidart\Menus\Presenters\Bootstrap\NavMenuPresenter |
Make A custom Presenter
You can create your own presenter classes. Make sure your presenter extends the Nwidart\Menus\Presenters\Presenter
and implements
the 'Nwidart\Menus\Presenters\PresenterInterface' interface.
For example, this is zurb-top-bar
presenter.
To use this custom presenter, you can use the setPresenter
method.
Register A New Menu Style
Menu style is like an alias to a presenter. You can register your style from your costum presenter in the configuration file in config/menus.php
.
Now, you can use a style like this.
View Presenter
If you don't like to use presenter classes, you use view presenters instead. We can set which view to present the menus by calling ->setView()
method.
The List of Available View Presenter
View Name | Menu Style |
---|---|
menus::default |
Bootstrap Navbar (default) |
menus::navbar-left |
Bootstrap Navbar Left |
menus::navbar-right |
Bootstrap Navbar Right |
menus::nav-tabs |
Bootstrap Nav Tabs |
menus::nav-tabs-justified |
Bootstrap Nav Tabs Justified |
menus::nav-pills |
Bootstrap Nav Pills |
menus::nav-pills-stacked |
Bootstrap Nav Pills Stacked |
menus::nav-pills-justified |
Bootstrap Nav Pills Justified |
menus::menu |
Plain Menu |
Rendering Menu
To render the menu you can use render
or get
method.
You can also set which style to present the menu in the second parameter.
Or you may also set which view to present the menu.
The Menu Instance
Sometimes, maybe we need to add a new additional menu from controller or other place. To get an instance of an existing menu, you can use the instance
method.
Finding Menu Item
To find menu item, you can use findBy
method from Nwidart\Menus\MenuBuilder
class.
You may also use whereTitle
helper method to find a specific menu item. Also, you can add other child menu item in the callback that located in the second argument in whereTitle
method.
Modifying Menu
After we create a menu, maybe we need to add other additional menus. You may modifying menu via ->modify
method.
All versions of laravel-menus with dependencies
illuminate/support Version 5.2.*|5.3.*|5.4.*
illuminate/config Version 5.2.*|5.3.*|5.4.*
illuminate/view Version 5.2.*|5.3.*|5.4.*
laravelcollective/html Version 5.2.*|5.3.*|5.4.*