We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not sure if I missed something, if it's by design or a bug.
class TestController extends ApiController { public function __construct(Request $request) { dd($request->user()); // null; } public function __invoke(Request $request) { dd($request->user()); // App\User; } }
How do i get the signed in user in the constructor?
The text was updated successfully, but these errors were encountered:
It's by design since the session hasn't been loaded yet. Here's a workaround using the middleware helper method.
public function __construct() { $this->middleware(function ($request, $next) { $request->user(); // your logic here... return $next($request); }); }
Sorry, something went wrong.
It worked, thanks @rcubitto
No branches or pull requests
Description:
Not sure if I missed something, if it's by design or a bug.
Steps To Reproduce:
How do i get the signed in user in the constructor?
The text was updated successfully, but these errors were encountered: