1. I have Employee table whose structure is as follows:
EmpId
FirstName
LastName
Username
Password
[b]2. Now in application component I have included my custom class as follows:
[/b]
‘user’ =>
[ ‘identityClass’ => ‘app\models\Employee’,
‘enableSession’ => true,
],
3.I have implemented foll methods in Employee model as follows:
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException();
}
public function getId()
{
return $this->EmpId;
}
public function getAuthKey()
{
throw new NotSupportedException();
}
public function validateAuthKey($authKey)
{
throw new NotSupportedException();
}
public static function findByUsername($username)
{
return self::findOne([‘Username’=>$username]);
}
public function validatePassword($password)
{
return $this->Password === $password;
}
4. And in LoginForm model, I have following. Insted of User, I have included custom class Employee.
public function getUser()
{
if ($this->_user === false)
{
$this->_user = Employee::findByUsername($this->username);
}
return $this->_user;
}
5. Now when I try to login and provide username and password, it gives the foll error:
Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: app\models\Employee::username