在这个主题中,我问了一个问题:Laravel 5.2 auth更改'用户'表
但现在我的问题已经改变了.默认情况下,users表有一个id
.但我想要一个customer_id
,所以我改变了一切,但它不起作用.它不断要求id
.
SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'id'(SQL:select*from
klanten
whereid
= 1 limit 1)
在表中klanten
我有一个customer_id
,但它一直在要求id
.
我改变的事情:
配置/ AUTH
'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, 'table' => 'klanten', ],
创建了一个klanten
迁移
public function up() { Schema::create('klanten', function (Blueprint $table) { $table->increments('klant_id'); $table->string('voornaam'); $table->string('email')->unique(); $table->string('password', 64); $table->rememberToken(); $table->boolean('status'); $table->timestamps(); }); }
如果我删除时间戳它一直要求created_at
和updated_at
太.
控制器/认证/ AuthController
protected function validator(array $data) { return Validator::make($data, [ 'voornaam' => 'required|max:255', 'email' => 'required|email|max:255|unique:klanten', 'password' => 'required|confirmed|min:6', ]); } protected function create(array $data) { return User::create([ 'voornaam' => $data['voornaam'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); }
应用/用户
protected $table = 'klanten'; protected $fillable = [ 'voornaam', 'email', 'password', ];
我希望有人可以帮助我!
编辑您的用户模型并添加以下内容:
protected $primaryKey = 'customer_id';