yii2-usuario
yii2-usuario copied to clipboard
Add a custom field to profile
I'd like to add a custom field to profile (well, indeed, several ;-) I wonder if the good way to do is to "override" profile model. Should I modify the "profile" table first ? I mean, I create a new column in the MySQL profile table called "gender".
Then the good way would be ... ?
common\models\Profile.php
<?php
namespace common\models;
use Da\User\Model\Profile as BaseProfile;
class Profile extends BaseProfile
{
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'gender' => Yii::t('usuario', 'Gender'),
];
}
}
And in the containers definition:
'container' => [
'definitions' => [
Da\User\Model\Profile::class => common\models\Profile::class,
],
],
This is it ? So simple ? I mean, I've tested and it's working but I wonder if that's the best way to do with yii2-usuario
@skiiiks is good