laravel auth user_id
$userId = Auth::id();
laravel auth user_id
$userId = Auth::id();
auth::check() and auth::user() what diferent
Auth::check() defers to Auth::user().
It's been that way since as long as I can remember.
In other words, Auth::check() calls Auth::user(), gets the result from it,
and then checks to see if the user exists.
The main difference is that it checks if the user is null for you
so that you get a boolean value.
This is the check function:
public function check()
{
return ! is_null($this->user());
}
As you can see, it calls the user() method, checks if it's null,
and then returns a boolean value.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us