97 lines
2.4 KiB
PHP
97 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace backend\modules\api\models;
|
|
|
|
use Yii;
|
|
|
|
/**
|
|
* This is the model class for table "user".
|
|
*
|
|
* @property int $id
|
|
* @property string $username
|
|
* @property string $auth_key
|
|
* @property string $password_hash
|
|
* @property string $password_reset_token
|
|
* @property string $email
|
|
* @property int $status
|
|
* @property int $created_at
|
|
* @property int $updated_at
|
|
* @property string $access_token
|
|
* @property string $access_token_expired_at
|
|
*
|
|
* @property UserCard[] $userCards
|
|
* @property UserQuestionnaire[] $userQuestionnaires
|
|
* @property UserResponse[] $userResponses
|
|
*/
|
|
class User extends \common\models\User
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'user';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['username', 'auth_key', 'password_hash', 'email', 'created_at', 'updated_at'], 'required'],
|
|
[['status', 'created_at', 'updated_at'], 'integer'],
|
|
[['access_token_expired_at'], 'safe'],
|
|
[['username', 'password_hash', 'password_reset_token', 'email', 'access_token'], 'string', 'max' => 255],
|
|
[['auth_key'], 'string', 'max' => 32],
|
|
[['username'], 'unique'],
|
|
[['email'], 'unique'],
|
|
[['password_reset_token'], 'unique'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'username' => 'Username',
|
|
'auth_key' => 'Auth Key',
|
|
'password_hash' => 'Password Hash',
|
|
'password_reset_token' => 'Password Reset Token',
|
|
'email' => 'Email',
|
|
'status' => 'Status',
|
|
'created_at' => 'Created At',
|
|
'updated_at' => 'Updated At',
|
|
'access_token' => 'Access Token',
|
|
'access_token_expired_at' => 'Access Token Expired At',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return \yii\db\ActiveQuery
|
|
*/
|
|
public function getUserCards()
|
|
{
|
|
return $this->hasMany(UserCard::className(), ['id_user' => 'id']);
|
|
}
|
|
|
|
/**
|
|
* @return \yii\db\ActiveQuery
|
|
*/
|
|
public function getUserQuestionnaires()
|
|
{
|
|
return $this->hasMany(UserQuestionnaire::className(), ['user_id' => 'id']);
|
|
}
|
|
|
|
/**
|
|
* @return \yii\db\ActiveQuery
|
|
*/
|
|
public function getUserResponses()
|
|
{
|
|
return $this->hasMany(UserResponse::className(), ['user_id' => 'id']);
|
|
}
|
|
}
|