caffeinated / menus

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

Non static method error #72

Closed windhorst closed 8 years ago

windhorst commented 8 years ago

Whenever I try to use this package I am getting a "Non-static method Caffeinated\Menus\Menu::make() should not be called statically, assuming $this from incompatible context" error. I'm fairly sure it is something that I can doing wrong but I have yet to figure out what it is. Middleware:

namespace App\Http\Middleware;
use Closure;
use Caffeinated\Menus\Menu as Menu;
class MenuWare
{

Usage inside a method in my middleware class:

Menu::make('AdminMenu', function($menu){
                $menu->add('Dashboard', '/admin');
                $menu->add('Users', '/admin/users');
                $menu->add('Products', '/admin/products');
                $menu->add('Organizations', '/admin/organizations');
});

Providers added as: 'Caffeinated\Menus\MenusServiceProvider',

Alias added as: 'Menu' => 'Caffeinated\Menus\Facades\Menu',

Any help on this would be greatly appreciated.

kaidesu commented 8 years ago

Get rid of the use Caffeinated\Menus\Menu as Menu; line and simply replace it with use Menu;.

windhorst commented 8 years ago

Thanks for the help. I can't believe I missed that.

windhorst commented 8 years ago

Well, I thought that had indeed fixed things but it turns out I was in a conditional that simply didn't hit that code block. I switched the use statement to use Menu, however when I try to call

Menu::make('PublicMenu', function($menu){
                $menu->add('Features', '/pages/features');
                $menu->add('Support', '/pages/support');
                $menu->add('Libraries', '/pages/libraries');
                $menu->add('Publishers', '/pages/publishers');
                $menu->add('FAQ', '/pages/faq');
                $menu->add('Subscribe', '/subscribe');
                $menu->add('Contact', '/pages/contact');
                $menu->add('Login', '/pages/login');
            });

I get a "Class 'Menu' not found" error. The rest of my code is the same as the original post.