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

I think you should look for middleware instead. https://laravel.com/docs/5.4/middleware

0

can't we just define a constructor?

public function __construct()
{
    if (blah) {
         dd('xxxxxxxxxxx');
    }
}

I don't know about that, just asking.

0

What are you looking for? Do you want your controller to instantiate some data that you need for each method in that controller? You might indeed do that in the constructor.

If you only need some logic to be executed before going to the controller that doesn't really need to be available within the controller itself, I agree with Erik that you'd need to be looking at middleware instead.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

desbest desbest Joined 25 May 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.