简体   繁体   中英

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. But I use access in laravel 5.3

event(new UserLoggedIn(access()->user()));
  1. access() is an user define method in the following directory
Directory : /app/helpers.php

Codes : 
   if (! function_exists('access')) {
        /**
        * Access (lol) the Access:: facade as a simple function.
        */
        function access()
        {
           return app('access');
        }
    }
  1. auth() is a Laravel define method in the following directory
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);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM