W3cubDocs

/Laravel 8

GuardHelpers

trait GuardHelpers (View source)

These methods are typically the same across all guards.

Properties

protected Authenticatable $user The currently authenticated user.
protected UserProvider $provider The user provider implementation.

Methods

Authenticatable authenticate()

Determine if current user is authenticated. If not, throw an exception.

bool hasUser()

Determine if the guard has a user instance.

bool check()

Determine if the current user is authenticated.

bool guest()

Determine if the current user is a guest.

int|string|null id()

Get the ID for the currently authenticated user.

$this setUser(Authenticatable $user)

Set the current user.

UserProvider getProvider()

Get the user provider used by the guard.

void setProvider(UserProvider $provider)

Set the user provider used by the guard.

Details

Authenticatable authenticate()

Determine if current user is authenticated. If not, throw an exception.

Return Value

Authenticatable

Exceptions

AuthenticationException

bool hasUser()

Determine if the guard has a user instance.

Return Value

bool

bool check()

Determine if the current user is authenticated.

Return Value

bool

bool guest()

Determine if the current user is a guest.

Return Value

bool

int|string|null id()

Get the ID for the currently authenticated user.

Return Value

int|string|null

$this setUser(Authenticatable $user)

Set the current user.

Parameters

Authenticatable $user

Return Value

$this

UserProvider getProvider()

Get the user provider used by the guard.

Return Value

UserProvider

void setProvider(UserProvider $provider)

Set the user provider used by the guard.

Parameters

UserProvider $provider

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Auth/GuardHelpers.html