Laravel工匠路线:列表显示非对象异常


Laravel artisan route:list shows non-object Exception

我是新来的laravel。最近我从github克隆了一个样本项目。当我尝试执行php artisan route:list时,显示

PHP Fatal error:  Call to a member function getMemberType() on a non-object in /...app/Http/Controllers/Admin/BaseAdminController.php on line 91
[Symfony'Component'Debug'Exception'FatalErrorException]    
Call to a member function getMemberType() on a non-object  

BaseAdminController.php

public function __construct(EmployeeDetails $employeeDetails)
    {
        $this->middleware('auth');
        if(Auth::user()->getMemberType() != 'employee') //Line 91
        {
            Auth::logout();
            return Redirect::to('secure/login');
        }

当你触发工匠任务时,用户对象没有设置,所以'Auth::user()返回null,你看到这个错误。

这就是为什么你必须检查你的应用程序是否在控制台运行。您可以通过'App::runningInConsole()方法来实现。