Файл: gapps/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
Строк: 70
<?php
namespace IlluminateAuth;
use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
/**
* These methods are typically the same across all guards.
*/
trait GuardHelpers
{
/**
* The currently authenticated user.
*
* @var IlluminateContractsAuthAuthenticatable
*/
protected $user;
/**
* The user provider implementation.
*
* @var IlluminateContractsAuthUserProvider
*/
protected $provider;
/**
* Determine if the current user is authenticated.
*
* @return IlluminateContractsAuthAuthenticatable
*
* @throws IlluminateAuthAuthenticationException
*/
public function authenticate()
{
if (! is_null($user = $this->user())) {
return $user;
}
throw new AuthenticationException($this);
}
/**
* Determine if the current user is authenticated.
*
* @return bool
*/
public function check()
{
return ! is_null($this->user());
}
/**
* Determine if the current user is a guest.
*
* @return bool
*/
public function guest()
{
return ! $this->check();
}
/**
* Get the ID for the currently authenticated user.
*
* @return int|null
*/
public function id()
{
if ($this->user()) {
return $this->user()->getAuthIdentifier();
}
}
/**
* Set the current user.
*
* @param IlluminateContractsAuthAuthenticatable $user
* @return $this
*/
public function setUser(AuthenticatableContract $user)
{
$this->user = $user;
return $this;
}
}