yii 2 : override user model
model, yii2
Solution
There are 2 things you can set up: 1)
'user' => [
'identityClass' => 'common\models\User',
],
and 2
'user' => [
'class' => 'frontend\components\User',
],
You are switching them around. 'identityClass' is your model, 'class' is the the User component for Yii. By setting identityClass you are telling Yii that the User Component should use frontend\models\User it's identityClass property.
This is the User component https://github.com/yiisoft/yii2-framework/blob/master/web/User.php
The previous versions of Yii2 had actually the file frontend\components\User.php already put in (that was extending yii\web\User). I can see why it is more confusing now.
What is the new error you are getting?
Problem
How to override user model properly in yii2? For example, I want to override common\models\User.php I created frontend\models\User.php with the following code : ``` namespace frontend\models; use common\models\User as BaseUser; class User extends BaseUser { public static function tableName() { return '{{%accounts}}'; } ... ``` In main.php, when I add ``` 'user'=>array( 'class' => 'frontend\models\User', ), ``` I get error Setting unknown property: frontend\models\User::identityClass