caffeinated / menus

:pushpin: Menu generator package for the Laravel framework
https://caffeinatedpackages.com
132 stars 59 forks source link

Call to undefined method Caffeinated\Menus\Facades\Menu::make() #36

Closed dmcdenissen closed 9 years ago

dmcdenissen commented 9 years ago

I've got the same error as an previous ticket that was closed with a solution that wasn't the correct one... (Call to undefined method Caffeinated\Menus\Facades\Menu::make())

I installed it by using the "Installation" section within the Menus wiki (https://github.com/caffeinated/menus/wiki/Installation) Then I commented 'Caffeinated\Menus\MenusServiceProvider' in the config/app.php (providers) And added 'App\Providers\MenuServiceProvider' to config/app.php (providers) I created the file MenuServiceProvider.php within App/Providers and used the code from the Wiki (https://github.com/caffeinated/menus/wiki/Quick-Start)

kaidesu commented 9 years ago

From a clean Laravel installation, I followed every step (verbatim) from both the installation and quick start wiki pages, and I didn't run into any issues.

I would double check your namespace and use calls to make sure everything is configured correctly. If you're still having issues, you can post your files here and I can take a look over them.

dmcdenissen commented 9 years ago

App\Providers\MenuServiceProvider.php

<?php
namespace App\Providers;

use Menu;
use Illuminate\Support\ServiceProvider;

class MenuServiceProvider extends ServiceProvider
{
    /**
     * Boot the service provider.
     *
     * @return void
     */
    public function boot()
    {
        Menu::make('admin_menu', function($menu) {
            $menu->add('Home', '/');
        }
        );
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

config\app.php

<?php 
...
    'providers' => [
...
        'Caffeinated\Modules\ModulesServiceProvider',
        // 'Caffeinated\Menus\MenusServiceProvider', (<- Commented because of new serviceprovider below)
        'App\Providers\MenuServiceProvider'
    ],

    'aliases' => [
...
        'Module'    => 'Caffeinated\Modules\Facades\Module',
        'Menu'      => 'Caffeinated\Menus\Facades\Menu'
         ],
];

Caffeinated\menus is located in: vendor\caffeinated\menus (Haven't changed anything) And Menu.php within the caffeinated\menus :

<?php
namespace Caffeinated\Menus;

use Collective\Html\HtmlBuilder;
use Illuminate\Config\Repository;
use Illuminate\Routing\UrlGenerator;
use Illuminate\View\Factory;

...
kaidesu commented 9 years ago

Well there's your issue - you shouldn't have commented out Caffeinated\Menus\MenusServiceProvider.

You creating your own MenuServiceProvider does not replace the one provided by the package. Your MenuServiceProvider is simply a location to create your menus in. You can name your MenuServiceProvider provider anything you like as well, if it's confusing in any way.

dmcdenissen commented 9 years ago

Lol, it was that simple :'( sorry for bothering... You can close the ticket

kaidesu commented 9 years ago

No worries man! Code on :+1: