I'm creating a messaging application. User logs in and then his conversations are displayed to him.
i used Auth::attempt
to check the user(after he submits the login form) . After successful login, he is redirected to a route(conversations) which uses respective controller method(HomeController@conversations).
In the method, i need to know the user's id so that i could fetch his conversation list. SO i need to use Auth::user()->id
, wherever needed.
NOw when i'm using Auth::user()->id
, it is showing an error(trying to get property from non-object).
i tried print_r(Auth::user) and the result was blank.
On localhost, everthing is working fine, but i'm facing this issue on the live server. Auth::attempt
is working fine, but Auth::check()
and Auth::user()
are not.