Laravel-Backpack/MenuCRUD

Base/helpers functions return null

kpapag opened this issue · 4 comments

Bug report

What I did:

Installed MenuCRUD and extended it from my custom class

What I expected to happen:

To be able to use helpers functions like backpack_user(), etc

What happened:

helpers functions keep returning null

What I've already tried to fix it:

Also tried editing the derived files and use stock MenuCRUD, in case my extension messed this up, but it still does not work

Backpack: 3.6, Laravel: 5.8, PHP: 7.3.5, DB version: MySQL 5.7.26

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

Ok so the problem seems to be that the latest versions of MenuCRUD (also applies to NewsCRUD) for Backpack 3.6 use crudcontrollers that do not initialize the public function setup(). public function __construct() seems to be used so im guessing thats the issue. Can someone confirm? Also will there be any fixes for these packages or support moved to backpack v4?

Thanks

Hi @kpapag ,

Sorry to hear you're having issue. Indeed - we're only pushing fixes for the Backpack v4 version at this moment.

However, if you've already extended the MenuItemCrudController, and the problem is that _construct() is used instead of setup(), you should be able to use setup() in your extended controller. I doubt that's the problem though - the helpers are loaded by Laravel, if Backpack\Base is installed. So they should be available inside any .php file that Laravel loads. At least that's how I see it.

Personally, I never use MenuCRUD and NewsCRUD as installed packages (and extending the classes in the package). I just copy-paste the code to my project and modify as needed. I think it works A LOT better that way, since they provide very simple functionality, and every project needs something different in terms of menus/blog.

Cheers!

Hey @tabacitu

Okay so i just tested it and indeed it was the use of _construct() that did not load the helpers function. When i used the setup() i was able to use the helpers functions again. Weird?

I'm writing this so if anyone has the same problem can fix this.

Thanks