Utility to generate an intelligent "range" of links based on the current page and total pages.
Install via composer in your project :
composer require anekdotes/menus
Load the class
use Anekdotes\Menus\Menus;
Add menu using the class' method
Menus::addItem('test 1', '/test1', 'fa-potato');
You can also specify the level and position
Menus::addItem('test 1', '/test1', 'fa-potato', 1, 1);
You can also add a namespace
Menus::addItem('test 1', '/test1', 'fa-potato', 1, 1, 'potato');
Fetch all main menus
$items = Menus::main();
Or get all menus from a desired level and namespace
$items = Menus::get('potato', 1);
Method to add an item to the menu's array
Menus::addItem($title, $url, $icon, $level, $position, $namespace);
//$title the link title/name/text
//$url the link url
//$icon the link icon (font-awesome, ex: fa-times)
//$level the link level (default: 1)
//$position the link position (default: 0)
//$namespace the link namespace (default: "")
Method to remove an item from the menu's array
Menus::removeItem($level, $position);
//$level link level
//$position the link position
Method to find a specific item from the menu's array
Menus::find($level, $position);
//$level link level
//$position the link position
Method to get all level 1 item
Menus::main($sort);
//$sort sorting either SORT_ASC or SORT_DESC (default: SORT_ASC)
Method to clear all items from menu's array
Menus::clear();
Method to get all item from desired level and namespace
Menus::get($namespace, $level);
//$namespace the link namespace (default: "")
//$level the link level (default: 1)