I am trying to use email as my table's primary key, so my eloquent code is-
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class UserVerification extends Model
{
protected $table = 'user_verification';
protected $fillable = [
'email',
'verification_token'
];
//$timestamps = false;
protected $primaryKey = 'verification_token';
}
And my DB is like this-
but if I do this-
UserVerification::where('verification_token', $token)->first();
I am getting this-
{
"email": "sdfsdf@sdfsdf.sdf",
"verification_token": 0,
"created_at": "2016-01-03 22:27:44",
"updated_at": "2016-01-03 22:27:44"
}
So, the verification token/primary key becomes 0.
Can anyone please help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…