2015-09-02 22 views
2

我是laravel的新手。最近我從github克隆了示例項目。當我嘗試執行php artisan route:list顯示Laravel工匠路線:列表顯示非對象例外

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'); 
     } 
+0

您克隆了哪個示例項目? –

回答

2

當你火工匠任務,用戶對象沒有設置,所以\Auth::user()回報null,你會看到這個錯誤。

這就是爲什麼你必須檢查你的應用程序是否在控制檯中運行。你可以通過\App::runningInConsole()方法來完成。