Omar Ajmi
Omar Ajmi

Reputation: 180

Laravel's Auth::user() returns null

I changed my Laravel file structure like this file structure.

I won't discuss how cause it's long but everything works fine and now if I want to access the Auth::user() or anything from Auth from the new Controllers, Views or Models locations it returns errors or null, and when i access the Auth from the routes/web.php it works fine so something in my new configuration is missing any ideas how to fix it? any file code is needed just ask me to put it, Thanks.

Upvotes: 1

Views: 1991

Answers (1)

Omar Ajmi
Omar Ajmi

Reputation: 180

Thanx for the "hint" @lagbox gave me but i figured it out. i just needed to add the web middleware the the route in my User/routes.php like so:

Route::group(['prefix' => 'users', 'namespace' => 'App\Modules\User\Controllers'], function(){
    Route::get('/profile', ['as' => 'profile', 'uses' => 'UsersController@profile'])->middleware('web');
           );

Upvotes: 1

Related Questions