W3cubDocs

/Laravel 8

RequestGuard

class RequestGuard implements Guard (View source)

Traits

GuardHelpers These methods are typically the same across all guards.
Macroable

Properties

protected Authenticatable $user The currently authenticated user. from GuardHelpers
protected UserProvider $provider The user provider implementation. from GuardHelpers
static protected array $macros The registered string macros. from Macroable
protected callable $callback The guard callback.
protected Request $request The request instance.

Methods

Authenticatable authenticate()

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

from GuardHelpers
bool hasUser()

Determine if the guard has a user instance.

from GuardHelpers
bool check()

Determine if the current user is authenticated.

from GuardHelpers
bool guest()

Determine if the current user is a guest.

from GuardHelpers
int|string|null id()

Get the ID for the currently authenticated user.

from GuardHelpers
$this setUser(Authenticatable $user)

Set the current user.

from GuardHelpers
UserProvider getProvider()

Get the user provider used by the guard.

from GuardHelpers
void setProvider(UserProvider $provider)

Set the user provider used by the guard.

from GuardHelpers
static void macro(string $name, object|callable $macro)

Register a custom macro.

from Macroable
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

from Macroable
static bool hasMacro(string $name)

Checks if macro is registered.

from Macroable
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

from Macroable
void __construct(callable $callback, Request $request, UserProvider $provider = null)

Create a new authentication guard.

Authenticatable|null user()

Get the currently authenticated user.

bool validate(array $credentials = [])

Validate a user's credentials.

$this setRequest(Request $request)

Set the current request instance.

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

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(callable $callback, Request $request, UserProvider $provider = null)

Create a new authentication guard.

Parameters

callable $callback
Request $request
UserProvider $provider

Return Value

void

Authenticatable|null user()

Get the currently authenticated user.

Return Value

Authenticatable|null

bool validate(array $credentials = [])

Validate a user's credentials.

Parameters

array $credentials

Return Value

bool

$this setRequest(Request $request)

Set the current request instance.

Parameters

Request $request

Return Value

$this

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