Adding them to the baseController I would think. That way ALL controllers will have access.
Hi,
Thanks, I already actually tried creating a BaseController and adding the following code just to test:
public function __construct(){
var_dump("test");
}
But I'm not getting anything back, Is there anything else that I need to initialise? I'm using Laravel 5.
I also referred to this post: https://laracasts.com/discuss/channels/general-discussion/laravel-5-basecontroller which says that I just need to make a basecontroller and that it should be inherited to other controllers but it hasn't worked for me.
In order to call parent baseController construct you have to do this in the child controller that extends baseController
public function __construct(){
parent::__construct();
}
play around with prepending parent:: to the parent's functions in your child controller.
like make a function in the parent that returns the data you want, then in the child call parent::myParentFunction();
but as that post suggests, you will need to make a BaseController Class if it does not exist, then just extend it with all of your regular controllers.
P.S. - haven't played with L5 yet, wasn't aware they got rid of the BaseController. But it is as simple as making the file, declaring the class, and extending it.
Thanks for all your help. Yep in L5 they got rid of the basecontroller, but exactly as you said simple to just make the file.
Much appreciated. Once again thanks. :)
Hi,
I would prefer to create a Facade and use it across your website.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community