I'm having a big problem with Auth:attempt method in laravel 5.2, and I wish I can override it.
I have the class users, by default, but doesn't containt the attribut 'email', this last one is containing in an other class user_contacts, with relation one to one with users.
Can I override this function? because by default, it takes 'email', which is not in users in my case I tried to make that in the model, but not working:
lass User extends Authenticatable
{
public function __construct(array $attr = array())
{
parent::__construct($attr);
$this->email = $this->user_contacts()->email;
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function user_contacts()
{
return $this->hasOne('App\UserContact', 'user_id', 'id');
}
}
It just says that the email field is not defined.
Any suggestion plz?
Thanks alot.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire