Menu

Introduction

Some apps might have additional pages available in admin section, besides what will be available via the settings. Take for example an e-commerce app that adds Products to Strata. You would likely create some additional models and would want a way for the backend user have a way to do some CRUD actions on them. Strata makes it easy to hook into the sidebar menu and add your own items.

Adding menu items

When you're registering your app you can also add your own menu items to the sidebar. These will only show up if the app has been enabled. The menu() function expects a closure that provides you with the Helix\Lego\Menus\Menu.

1use Helix\Lego\LegoManager;
2use Helix\Lego\Menus\Lego\Link;
3use Helix\Lego\Menus\Menu;
4use Helix\Fabrick\Icon;
5 
6return $app
7 ->name('e-commerce')
8 ->menu(function (Menu $menu) {
9 $menu->addToSection(Menu::MAIN_SECTIONS['PRIMARY'],
10 Link::to(route('lego.products.index'), 'Products')
11 ->after('Pages')
12 ->icon(Icon::SHOPPING_BAG)
13 );
14 })

Icons are from heroicons and provide via the "Fabrick" package.

Grouping items

It is also possible to group items of similar nature. The first argument is the name of the group, the second is an array of the items in the group, and the last is the icon for the group.

1return $app
2 ->name('e-commerce')
3 ->menu(function (Menu $menu) {
4 $menu->addToSection(Menu::MAIN_SECTIONS['PRIMARY'],
5 Group::add(
6 'Pages',
7 [
8 Link::to(route('lego.pages.index'), 'Pages'),
9 Link::to(route('lego.landing-pages.index'), 'Landing Pages'),
10 ],
11 Icon::DOCUMENT_TEXT,
12 )
13 );
14 })