本文整理汇总了PHP中Illuminate\Auth\AuthManager::guard方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthManager::guard方法的具体用法?PHP AuthManager::guard怎么用?PHP AuthManager::guard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\AuthManager
的用法示例。
在下文中一共展示了AuthManager::guard方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guard()->check()) {
return $this->redirect->route('admin', $this->app->getLocale());
}
return $next($request);
}
示例2: getUser
/**
* Get User
*
* @return \Illuminate\Contracts\Auth\Authenticatable
*/
protected function getUser()
{
if (!$this->user) {
$authGuard = $this->config->get('nwlaravel.activity.auth_guard') ?: $this->auth->getDefaultDriver();
$this->user = $this->auth->guard($authGuard)->user();
}
return $this->user;
}
示例3: __construct
public function __construct(AuthManager $auth, Repository $config)
{
$this->auth = $auth;
$this->properties = collect();
$authDriver = $config['laravel-activitylog']['default_auth_driver'] ?? $auth->getDefaultDriver();
if (starts_with(app()->version(), '5.1')) {
$this->causedBy = $auth->driver($authDriver)->user();
} else {
$this->causedBy = $auth->guard($authDriver)->user();
}
$this->logName = $config['laravel-activitylog']['default_log_name'];
$this->logEnabled = $config['laravel-activitylog']['enabled'] ?? true;
}
示例4: guard
/**
* Attempt to get the guard from the local cache.
*
* @param string $name
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
* @static
*/
public static function guard($name = null)
{
return \Illuminate\Auth\AuthManager::guard($name);
}
示例5: getLogout
/**
* Log the user out of the admin and redirect him to auth page
*
* @return \Illuminate\Http\RedirectResponse
*/
public function getLogout()
{
$this->auth->guard()->logout();
return $this->redirect->route('auth');
}
示例6: __construct
/**
* Create a new basic provider instance.
*
* @param \Illuminate\Auth\AuthManager $auth
*/
public function __construct(AuthManager $auth)
{
$this->auth = $auth->guard($this->guard);
}