Home  >  Q&A  >  body text

html - How to use the Laravel-Menu plug-in

The laravel-menu plugin is installed in Laravel 5.2.31, and providers and aliases have been configured according to the instructions on Github.
But whether it is through middleware or adding the navigation menu in routes.php, it cannot be used in the blade page{!! Menu::get('MyNavBar')->asUl() !!} will promptMethod get does not exist!
Solution!

怪我咯怪我咯2737 days ago500

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 16:55:04

    
    namespace App\Http\Controllers;
    use Menu;
    
    class TestController extends Controller
    {
        public function Index()
        {
            $MyNavBar = Menu::make('MyNavBar', function($menu){
    
              $menu->add('Home');
              $menu->add('About',    'about');
              $menu->add('services', 'services');
              $menu->add('Contact',  'contact');
    
            })->asUl();
            
            return view('test',[
                'MyNavBar'=>$MyNavBar
            ]);
        }
    }
    
    
    
    #views
    <html>
        <head>
            <title>Test</title>
        </head>
        <body>
            <p class="container">
            {!! $MyNavBar !!}
            </p>
        </body>
    </html>
    

    reply
    0
  • Cancelreply