Reputation: 150
I have tried to access Auth::user() object in group function in Web.php file but it return null value. PLease look my code of web.php file.
Auth::routes();
Route::group(['domain' => 'local.proaisys.com','middleware' => ['auth']], function(){
//dd(\Auth::check());
dd(Auth::user());
Route::get('/dashboard','DashboardController@crm');
});
Upvotes: 1
Views: 1056
Reputation: 1048
What you are trying to achieve here!!
This is you routes/web.php
file. You need to pass your query inside function, not outside that. How will route know that you need user inside route!!
Try this:
Route::group(['domain' => 'local.proaisys.com','middleware' => ['auth']], function(){
//dd(\Auth::check());
Route::get('/dashboard',function() {
dd(Auth::user());
//Now goto your domain.com/dashboard your will get user
});
});
Or you can get dd(Auth::user())
in your function DashboardController@crm
You need to give some route in which you want, but you are trying to access it from outside of function.
Hope it helps...Enjoy
Upvotes: 2
Reputation: 2172
If you have primary key in your users
table, named other than id
then it may cause this problem.
The primary key in users
table should be named as id
(case-sensitive).
Upvotes: 0
Reputation: 2993
Try to login your account. Then try to check again. if Auth::user() returns null again. try to check this link https://laracasts.com/discuss/channels/laravel/authuser-returns-null-in-laravel-52
Upvotes: 0