Learn how to get the current user (or other session data) in a Laravel controller constructor
Joseph Silber shows us how to get the current user in a Laravel controller constructor.
Let's discuss something many people have accidentally discovered: you cannot use session data directly in a controller's constructor.
This change was introduced in Laravel 5.3, when the middleware pipeline was rewired to make global scopes work with session data.
In this post we'll examine the problem in more detail, and look at various ways to solve it.
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Tips Tricks Laravel 5 Intermediate Laravel 5.3 Laravel 5.4