Php Laravel 5.7 Gate::allows非静态方法Illumb\Auth\Access\Gate::allows()不应静态调用

Php Laravel 5.7 Gate::allows非静态方法Illumb\Auth\Access\Gate::allows()不应静态调用,php,laravel,Php,Laravel,在我的formRequest类中使用Gate::allows时,我在Laravel5.7中遇到了这个错误 我使用的是:use-illumb\Auth\Access\Gate但它不起作用 所以我把它换成了:使用illumb\Support\Facades\Gate,它成功了 我真的需要知道为什么第一个不起作用,以及两者之间的区别。我试着查找资料,但我需要一个更直接和简洁的解释。 任何帮助或指点都将不胜感激 在Laravel应用程序中,facade是提供对 容器中的对象。使这项工作顺利进行的机器正在

在我的formRequest类中使用Gate::allows时,我在Laravel5.7中遇到了这个错误

我使用的是:
use-illumb\Auth\Access\Gate但它不起作用

所以我把它换成了:
使用illumb\Support\Facades\Gate
,它成功了

我真的需要知道为什么第一个不起作用,以及两者之间的区别。我试着查找资料,但我需要一个更直接和简洁的解释。 任何帮助或指点都将不胜感激

在Laravel应用程序中,facade是提供对 容器中的对象。使这项工作顺利进行的机器正在运转 门面类。Laravel的外观,以及您需要的任何定制外观 创建,将扩展基础Illumb\Support\Facades\Facade类

Facade基类使用_callStatic()魔术方法 延迟从外观到从容器解析的对象的调用。 在下面的示例中,调用了Laravel缓存系统。通过 浏览一下这段代码,我们可能会认为静态方法get是 正在缓存类上调用:

相反,缓存facade扩展了基本facade类并定义了 方法getFacadeAccessor()。此方法的任务是返回 服务容器绑定的名称。当用户引用任何静态 方法,Laravel从 服务容器并运行请求的方法(在本例中, 对着那个物体

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;

class UserController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return Response
     */
    public function showProfile($id)
    {
        $user = Cache::get('user:'.$id);

        return view('profile', ['user' => $user]);
    }
}
class Cache extends Facade {
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor() { return 'cache'; } }