[英]What is the difference between auth and access in Laravel 5.7?
When i use access in Laravel 5.7 it's not return or support.当我在 Laravel 5.7 中使用访问权限时,它不会返回或支持。 But I use access in laravel 5.3
但我在 laravel 5.3 中使用访问
event(new UserLoggedIn(access()->user()));
- access() is an user define method in the following directory
access() 是用户定义方法在以下目录
Directory : /app/helpers.php
Codes :
if (! function_exists('access')) {
/**
* Access (lol) the Access:: facade as a simple function.
*/
function access()
{
return app('access');
}
}
- auth() is a Laravel define method in the following directory
auth() 是 Laravel 定义方法在以下目录
Directory : /vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
Codes :
if (! function_exists('auth')) {
/**
* Get the available auth instance.
*
* @param string|null $guard
* @return \Illuminate\Contracts\Auth\Factory|\Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
*/
function auth($guard = null)
{
if (is_null($guard)) {
return app(AuthFactory::class);
} else {
return app(AuthFactory::class)->guard($guard);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.