getting problem with authentication in laravel as I have username and password in different tables.As Auth uses same table for username and password but my database is already s
I'd do something like this. Assuming a one-to-one relationship between your tables.
Define a relationship between User and WebpagesMembership models. Your User model would have the following:
public function webpagesMembership() {
return $this->hasOne(WebpagesMembership::class);
}
Add an accessor function
public function getPasswordAttribute() {
return $this->webpagesMembership->getAttribute('password');
}
That way Auth will work when it attempts to access the password attribute on your User model.
Edit:
Add password
to the User model's $appends
property:
protected $appends = [
'password'
];
This will act as if it were an attribute on the model now. The error you encountered was because the GenericUser
's attributes were being set in the constructor and password
did not exist. It then attempted to access password
in:
public function getAuthPassword()
{
return $this->attributes['password'];
}
Hence, the undefined index.