src/Http/Composers/MenuViewComposer.php
public function compose(View $view)
    {
        $menuItems = new Collection;

        foreach (config("sharp.menu", []) as $menuItemConfig) {
            if($menuItem = MenuItem::parse($menuItemConfig)) {
                $menuItems->push($menuItem);
            }
        }

        $view->with('sharpMenu', (object)[
            "name" => config("sharp.name", "Sharp"),
            "user" => sharp_user()->{config("sharp.auth.display_attribute", "name")},
            "menuItems" => $menuItems,
            "currentEntity" => isset($view->entityKey)
                ? explode(':', $view->entityKey)[0]
                : ($view->dashboardKey ?? null)
        ]);

        $view->with('hasGlobalFilters', sizeof(config('sharp.global_filters') ?? []) > 0);
    }
public function compose(View $view)
    {
        $menuItems = new Collection;

        foreach (config("sharp.menu", []) as $menuItemConfig) {
            if($menuItem = MenuItem::parse($menuItemConfig)) {
                $menuItems->push($menuItem);
            }
        }

        $view->with('sharpMenu', (object)[
            "name" => config("sharp.name", "Sharp"),
            "user" => sharp_user()->{config("sharp.auth.display_attribute", "name")},
            "menuItems" => $menuItems,
            "currentEntity" => isset($view->entityKey)
                ? explode(':', $view->entityKey)[0]
                : ($view->dashboardKey ?? null)
        ]);

        $view->with('hasGlobalFilters', sizeof(config('sharp.global_filters') ?? []) > 0);
    }
public function compose ( View $ view ) { $ menuItems = new Collection ; foreach ( config ( "sharp.menu" , [ ] ) as $ menuItemConfig ) { if ( $ menuItem = MenuItem :: parse ( $ menuItemConfig ) ) { $ menuItems -> push ( $ menuItem ) ; } } $ view -> with ( 'sharpMenu' , ( object ) [ "name" => config ( "sharp.name" , "Sharp" ) , "user" => sharp_user ( ) -> { config ( "sharp.auth.display_attribute" , "name" ) } , "menuItems" => $ menuItems , "currentEntity" => isset ( $ view -> entityKey ) ? explode ( ':' , $ view -> entityKey ) [ 0 ] : ( $ view -> dashboardKey ?? null ) ] ) ; $ view -> with ( 'hasGlobalFilters' , sizeof ( config ( 'sharp.global_filters' ) ?? [ ] ) > 0 ) ; }
Build the menu and bind it to the view.

@param View $view
@return void
Build the menu and bind it to the view .