2017-07-08 86 views
0

我已經安裝了Laravel 5.4並使用了php artisan make:auth。一切都很好,我建立了我的數據庫並遷移了一切。我還測試了登錄和註冊,並且工作完美。BadMethodCallException - 調用未定義的方法Illuminate Database Query Builder :: getAuthIdentifierName()

之後,我設法設置了我的其他控制器和模型。在我測試了一個控制器之後(基本上,我在數據庫中存儲一個圖像然後顯示它)。它存儲圖像然後顯示它工作得很好。

但是,從此我在嘗試登錄或註冊時收到錯誤消息。

當我嘗試訪問http://localhost:8000/loginhttp://localhost:8000/register我收到以下錯誤:

Call to undefined method Illuminate\Database\Query\Builder::getAuthIdentifierName()

對於這個我不完全相信,我應該分享其中我的代碼部分,但是這是我的模態user.php的:

namespace App; 
use Illuminate\Database\Eloquent\Model; 
use Illuminate\Notifications\Notifiable; 
use Illuminate\Foundation\Auth\User as Authenticatable; 

use App\User; 

class User extends Authenticatable 
{ 
    use Notifiable; 

    /** 
    * The attributes that are mass assignable. 
    * 
    * @var array 
    */ 


    protected $table = 'users'; 

    protected $fillable = [ 
     'name', 'email', 'password', 
    ]; 

    /** 
    * The attributes that should be hidden for arrays. 
    * 
    * @var array 
    */ 
    protected $hidden = [ 
     'password', 'remember_token', 
    ]; 
} 

預先感謝您的傢伙,如果你需要我的代碼的其他部分我會很樂意分享。

+1

分享您的路線和控制文件有一個表 –

回答

1

首先首輪php artisan migrate的確保你在你的數據庫

User.php // user model add a primary key to get rid of this error

protected $primaryKey = 'yourPrimaryKey'; 
相關問題