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 setup where the the username is in table users and the password is in table webpages_membership, and I cant change the database structure because that database is used by other mobile application and website too. So how do I use Auth for login system.
@btl:
I tried the solution but now there is another error of
"Undefined index: password" in vendor\laravel\framework\src\Illuminate\Auth\GenericUser.php
following is my user model code.
Code:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\WebPages_Membership;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'Users';
protected $dbPrefixOveride = '';
protected $primaryKey = 'UserId';
protected $fillable = [
'Username', 'FirstName', 'LastName','Email','MobileNumber','CreatedBy','CreatedDate','ModifiedBy','ModifiedDate','DistributorId','Telephone','IsAuthorized','AlternateMobileNumber','AlternateEmail','IsDeleted','UnauthorizationRemark'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
/*protected $hidden = [
'password', 'remember_token',
];*/
public function webpagesMembership() {
return $this->hasOne(WebPages_Membership::class);
}
public function getPasswordAttribute() {
return $this->webpagesMembership->getAttribute('Password');
}
}
?>
