Auth
final class Auth
Static entry point to the application's auth guard. Lazily constructs a single SessionGuard so every caller shares one resolved user per request, and forwards the common guard operations (check, user, id) to it. A guard may also be injected via setGuard() to support testing.
Constants
| DEFAULT_USER_MODEL |
The user model used when config/auth.php does not set user_model. |
Properties
| static private Guard|null | $guard | The shared guard instance for the current request, or null until first constructed. |
Methods
Determines whether a user is currently authenticated.
Gets the identifier of the currently authenticated user.
Sets the shared guard instance, replacing any existing one. Intended primarily for testing, where a guard backed by a fake provider or session can be injected. Passing null resets the guard so the next call to guard() constructs a fresh default instance.
Gets the currently authenticated user.
Resolves the application's user model class. Framework code uses this instead of importing App\Models\Users so Core does not depend on the application. Reads auth.user_model from config/auth.php and falls back to App\Models\Users.
Details
at line 37
static bool
check()
Determines whether a user is currently authenticated.
at line 44
static Guard
guard()
Returns the shared guard, constructing it on first use.
at line 59
static mixed
id()
Gets the identifier of the currently authenticated user.
at line 73
static void
setGuard(Guard|null $guard)
Sets the shared guard instance, replacing any existing one. Intended primarily for testing, where a guard backed by a fake provider or session can be injected. Passing null resets the guard so the next call to guard() constructs a fresh default instance.
at line 83
static Principal|null
user()
Gets the currently authenticated user.
at line 97
static string
userModel()
Resolves the application's user model class. Framework code uses this instead of importing App\Models\Users so Core does not depend on the application. Reads auth.user_model from config/auth.php and falls back to App\Models\Users.