Inheritance: extends Spatie\Menu\Menu, implements Illuminate\Contracts\Support\Htmlable, use trait Illuminate\Support\Traits\Macroable
Ejemplo n.º 1
1
 public function register()
 {
     Menu::macro('front', function () {
         return Menu::new()->setActiveFromRequest(locale());
     });
     Menu::macro('main', function () {
         return Menu::front()->addClass('nav__list')->url('/', 'Home');
     });
     Menu::macro('language', function () {
         return Menu::build(locales(), function (Menu $menu, string $locale) {
             return $menu->url($locale, strtoupper($locale));
         })->setActiveFromRequest();
     });
     Menu::macro('articleSiblings', function (Article $article) {
         return $article->siblings->reduce(function (Menu $menu, Article $article) {
             return $menu->url($article->fullUrl, $article->name);
         }, Menu::front());
     });
 }
Ejemplo n.º 2
0
 public function register()
 {
     Menu::macro('back', function () {
         return Menu::new()->setActiveClass('-active')->setActiveFromRequest('/blender');
     });
     Menu::macro('moduleGroup', function ($title) {
         return Menu::back()->addParentClass('menu__group')->setParentAttribute('data-menu-group', fragment("back.nav.{$title}"))->registerFilter(function (Link $link) {
             $link->addParentClass('menu__group__item');
         });
     });
     Menu::macro('module', function (string $action, string $name) {
         return $this->action("Back\\{$action}", fragment("back.{$name}"));
     });
     Menu::macro('backMain', function () {
         return Menu::back()->addClass('menu__groups')->setAttribute('data-menu-groups')->add(Menu::moduleGroup('content')->module('ArticlesController@index', 'articles.title')->module('NewsController@index', 'news.title')->module('PeopleController@index', 'people.title'))->add(Menu::moduleGroup('modules')->module('FragmentsController@index', 'fragments.title')->module('FormResponsesController@showDownloadButton', 'formResponses.title')->module('TagsController@index', 'tags.title'))->add(Menu::moduleGroup('users')->module('MembersController@index', 'members.title')->module('AdministratorsController@index', 'administrators.title'))->add(Menu::moduleGroup('system')->module('ActivitylogController@index', 'log.title')->module('RedirectsController@index', 'redirects.title')->module('StatisticsController@index', 'statistics.menuTitle'));
     });
     Menu::macro('backUser', function () {
         $avatar = Html::avatar(current_user(), '-small') . el('span.:response-desktop-only', current_user()->email);
         return Menu::new()->action('Back\\AdministratorsController@edit', $avatar, [current_user()->id])->html(view('back.auth._partials.logoutForm'));
     });
     Menu::macro('breadcrumbs', function (array $breadcrumbs) {
         return Menu::build($breadcrumbs, function (Menu $menu, $actionWithParameters, $label) {
             if (!is_array($actionWithParameters)) {
                 $actionWithParameters = [$actionWithParameters];
             }
             $action = array_shift($actionWithParameters);
             return $menu->action($action, $label, $actionWithParameters);
         })->addClass('breadcrumb')->setActiveFromRequest('/blender');
     });
 }
Ejemplo n.º 3
0
 public function register()
 {
     $this->app->bind(Menu::class, function () {
         return Menu::new();
     });
     $this->app->alias(Menu::class, 'menu');
 }