You should include what version of Laravel you are using as there are many.
"In previous versions of Laravel, you could access session variables or the authenticated user in your controller's constructor. This was never intended to be an explicit feature of the framework. In Laravel 5.3, you can't access the session or authenticated user in your controller's constructor because the middleware has not run yet.
As an alternative, you may define a Closure based middleware directly in your controller's constructor. Before using this feature, make sure that your application is running Laravel 5.3.4 or above:" - Upgrade guide from 5.2 to 5.3
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us