I have searched and found various results like these: auth()->user() is null in Laravel 5.2 and Auth::user() returns null
But, mine is still not working.
From the same discussion that the accepted answer links to, I found the following solution to work. Edit your /routes/web.php
file and surround your existing routes with Route::group('middleware' => 'web'])
, like so:
Route::group(['middleware' => 'web'], function () {
Auth::routes();
// The rest of your routes
});
As far as I understand, this will not have any security or other implications, as it is simply loading the web
middleware prior to processing the contained routes. If anyone knows of security or other concerns / ramifications, please post them in the comments on this answer.