- I have Employee table whose structure is as follows:
EmpId
FirstName
LastName
Username
Password
Now in application component I have included my custom class as follows:
'user' => [ 'identityClass' => 'app\models\Employee', 'enableSession' => true, ],
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; }
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;
}
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