2016-06-08 34 views
1

我有這樣的代碼Laravel + FatalErrorException在Collection.php線11:接口 '照亮 合同隊列 QueueableCollection' 未找到

use App\User; 

use Auth; 

use App\Http\Controllers\Controller; 

use App\Libraries\CustomLib; 

class UsersController extends Controller 
{ 

    public function postLogin(){ 
     // var_dump($_POST); 
     $email = \Input::get('username'); 
     $password = \Input::get('password'); 

     $user = User::where("email",$email)->first(); 
     var_dump($user_info); 
    } 
} 

我收到此錯誤:

FatalErrorException in Collection.php line 11: Interface 'Illuminate\Contracts\Queue\QueueableCollection' not found 

不確定這意味着什麼。

任何想法請如何解決這個問題。

謝謝!

+0

這是否只發生在** User **模型中,哪個版本是您的composer.lock文件中的laravel/framework? – TheFallen

+0

@TheFallen版本是'「版本」:「v5.2.36」' – PinoyStackOverflower

回答

-1

特定錯誤意味着從數據庫檢索到的作爲Laravel集合的記錄集合沒有實現QueueableCollection接口中概述的特定方法。這通常是由於缺少依賴關係。通常,Laravels模型允許序列化。在這種情況下,這是因爲用戶模型可用於發送密碼提醒等的電子郵件......當此接口丟失時,Laravel會拋出一個異常,指出無法實例化所需的組件。這種方法也被稱爲「編碼到接口」。

更多信息:

看起來你正在嘗試手動驗證。請確保您的應用程序\ User模型實現可驗證:

use Illuminate\Database\Eloquent\Model; 
use Illuminate\Contracts\Auth\Authenticable; 
use Illuminate\Auth\Authenticable as AuthenticableTrait; 

class User extends Model implements Authenticable { 
    use AuthenticableTrait; 
} 

這是覆蓋在文檔

https://laravel.com/docs/5.2/authentication#authenticating-users

爲了節省您去一趟現場,這裏是用你自己的例子的意譯例如:用戶的

use App\User; 

use Auth; 

use Illuminate\Support\Facades\Auth; 

use App\Http\Controllers\Controller; 

use App\Libraries\CustomLib; 

class UsersController extends Controller 
{ 

    public function postLogin() 
    { 
     $email = \Input::get('username'); 
     $password = \Input::get('password'); 

     if (Auth::attempt(['email' => $email, 'password' => $password])) { 
      // Authentication passed. Redirect to "dashboard" 
      return redirect()->route('dashboard'); 
     } 
    } 

} 

詳細現在可以通過驗證門面來訪問:

Auth::user()->name; 
Auth::user()->email; 
Auth::user()->id; 

Auth::user()與會話相關。如果啓用,記錄令牌也會設置爲允許登錄持續超出會話過期時間限制(我相信默認值爲2小時)的cookie。

的更多信息:

https://laracasts.com/discuss/channels/general-discussion/laravel-5-authattemp-method?page=1

**Edit:**命名空間的引進示範,糾正繼承

+0

** AuthenticableTrait **將如何解決** QueueableCollection **錯誤,該錯誤是** Eloquent **的聯繫人? – TheFallen

+0

我有一個類似的問題,它通過閱讀文檔並進一步深入瞭解得到解決:https://github.com/laravel/framework/search?utf8=%E2%9C%93&q=getQueueableIds%28%29如果它無法檢索模型集合的ID,則會引發此錯誤。非默認App \ User模型有時會導致與身份驗證,授權,排隊,序列化,反序列化等相關的錯誤。 –

+0

好的,但是錯誤是爲了一個缺失的界面和** Authenticable **性狀默認使用在Illuminate的用戶類中,它擴展** Illuminate \ Database \ Eloquent \ Model **,而不是** \ Eloquent **。 – TheFallen

0

我更新我的作曲家使用舊版本的照明/數據庫,它現在正在工作。我猜想問題在於新版本的雄辯。 "illuminate/database": "5.2.*""illuminate/database": "5.2.21"

相關問題