class Guard

Properties

static protected array<class-string, mixed> $defaultGuardNames
static protected Model>, string> $modelKeyNames
static protected array<string, null|Model>> $providerModels
static protected array<class-string, array<int, string>> $configAuthGuards
static protected array<string, null|Model>> $modelsForGuards

Methods

static Collection
getNames(string|Model $model)

Return a collection of guard names suitable for the model, as indicated by the presence of a $guard_name property or a guardName() method on the model.

static string|null
getProviderModel(string $provider)

Get the model class associated with a given provider.

static mixed
getDefaultGuardNameProperty(string $class)

Get the default guard_name property for a model class.

static Repository
config()

Get the config repository.

static Factory
auth()

Get the auth factory.

static string|null
normalizeName(string|null $guard)

Normalize an optional guard name.

static array
guards()

Get the configured auth guards.

static Collection
getConfigAuthGuards(string $class)

Get list of relevant guards for the $class model based on config(auth) settings.

static string|null
getModelForGuard(string $guard)

Get the model associated with a given guard name.

static string
getModelKeyName(string $modelClass)

Get a model's key name without repeatedly constructing the model.

static string
getDefaultName(string|Model $class)

Lookup a guard name relevant for the $class model and the current user.

static Authorizable|null
getPassportClient(string|null $guard)

Lookup a Passport guard.

static void
flushState()

Flush all static state.

Details

at line 46
static Collection getNames(string|Model $model)

Return a collection of guard names suitable for the model, as indicated by the presence of a $guard_name property or a guardName() method on the model.

Parameters

string|Model $model

Return Value

Collection

at line 74
static protected string|null getProviderModel(string $provider)

Get the model class associated with a given provider.

Parameters

string $provider

Return Value

string|null

at line 99
static protected mixed getDefaultGuardNameProperty(string $class)

Get the default guard_name property for a model class.

Parameters

string $class

Return Value

mixed

at line 111
static protected Repository config()

Get the config repository.

Return Value

Repository

at line 119
static protected Factory auth()

Get the auth factory.

Return Value

Factory

at line 127
static string|null normalizeName(string|null $guard)

Normalize an optional guard name.

Parameters

string|null $guard

Return Value

string|null

at line 137
static protected array guards()

Get the configured auth guards.

Return Value

array

at line 151
static protected Collection getConfigAuthGuards(string $class)

Get list of relevant guards for the $class model based on config(auth) settings.

Lookup flow:

  • get names of models for guards defined in auth.guards where a provider is set
  • filter for provider models matching the model $class being checked
  • keys() gives just the names of the matched guards
  • return collection of guard names

Parameters

string $class

Return Value

Collection

at line 178
static string|null getModelForGuard(string $guard)

Get the model associated with a given guard name.

Parameters

string $guard

Return Value

string|null

at line 199
static string getModelKeyName(string $modelClass)

Get a model's key name without repeatedly constructing the model.

Parameters

string $modelClass

Return Value

string

at line 207
static string getDefaultName(string|Model $class)

Lookup a guard name relevant for the $class model and the current user.

Parameters

string|Model $class

Return Value

string

at line 225
static Authorizable|null getPassportClient(string|null $guard)

Lookup a Passport guard.

Parameters

string|null $guard

Return Value

Authorizable|null

at line 257
static void flushState()

Flush all static state.

Return Value

void