Support the ongoing development of Laravel.io →
posted 9 years ago
Configuration
Last updated 2 years ago.
0

Adding them to the baseController I would think. That way ALL controllers will have access.

0

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.

0

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();

Last updated 9 years ago.
0

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.

Last updated 9 years ago.
0

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. :)

0

Hi,

I would prefer to create a Facade and use it across your website.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

drc83 drc83 Joined 16 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.