2017-07-08 148 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'; 
相关问题