Support the ongoing development of Laravel.io →
IOC Architecture
Last updated 2 years ago.
0

If the child classes do not implement their own constructor the parent constructor will still be called.
You only need to manually call the parent constructor if the child class needs its own constructor.

Last updated 2 years ago.
0

Ok, I found a workaround for my problem... But there's another problem:

Isn't it possible to Redirect in parent classes? Tried to do:

class ProjectBaseController {
	
	public function __construct() {
		if(true) {
			return Redirect::to('somewhere');
		}
	}

}

class ProjectController extends ProjectBaseController {
	
	public function showSomething() {
		dd('foo'); // should never been displayed, since parent class redirects us
	}

}

But the redirect isn't working :(

Last updated 2 years ago.
0

Using a filter in the parent class solved my problem.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nehalist nehalist Joined 24 Feb 2014

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.