Admin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "user".
  6. *
  7. * @property integer $id
  8. * @property string $username
  9. * @property integer $role
  10. * @property string $email
  11. * @property string $fio
  12. * @property string $at_org
  13. * @property integer $org_type
  14. * @property string $member_phone
  15. * @property string $fax
  16. * @property integer $status
  17. * @property string $password_hash
  18. * @property string $auth_key
  19. * @property integer $confirmed_at
  20. * @property string $unconfirmed_email
  21. * @property integer $blocked_at
  22. * @property string $registration_ip
  23. * @property integer $created_at
  24. * @property integer $updated_at
  25. * @property integer $flags
  26. *
  27. * @property SocialAccount[] $socialAccounts
  28. * @property Token[] $tokens
  29. */
  30. class Admin extends Profile
  31. {
  32. /**
  33. * @inheritdoc
  34. */
  35. public static function tableName()
  36. {
  37. return 'user';
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function rules()
  43. {
  44. return [
  45. [['username', 'role', 'email', 'fio', 'at_org', 'org_type', 'member_phone', 'fax', 'password_hash', 'auth_key', 'created_at', 'updated_at'], 'required'],
  46. [['role', 'org_type', 'status', 'confirmed_at', 'blocked_at', 'created_at', 'updated_at', 'flags'], 'integer'],
  47. [['username'], 'string', 'max' => 25],
  48. [['email', 'unconfirmed_email'], 'string', 'max' => 255],
  49. [['fio'], 'string', 'max' => 50],
  50. [['at_org'], 'string', 'max' => 30],
  51. [['member_phone', 'fax'], 'string', 'max' => 12],
  52. [['password_hash'], 'string', 'max' => 60],
  53. [['auth_key'], 'string', 'max' => 32],
  54. [['registration_ip'], 'string', 'max' => 45],
  55. [['username'], 'unique'],
  56. [['email'], 'unique']
  57. ];
  58. }
  59. /**
  60. * @inheritdoc
  61. */
  62. public function attributeLabels()
  63. {
  64. return [
  65. 'id' => Yii::t('app', 'ID'),
  66. 'username' => Yii::t('app', 'Username'),
  67. 'role' => Yii::t('app', 'Role'),
  68. 'email' => Yii::t('app', 'Email'),
  69. 'fio' => Yii::t('app', 'Fio'),
  70. 'at_org' => Yii::t('app', 'At Org'),
  71. 'org_type' => Yii::t('app', 'Org Type'),
  72. 'member_phone' => Yii::t('app', 'Member Phone'),
  73. 'fax' => Yii::t('app', 'Fax'),
  74. 'status' => Yii::t('app', 'Status'),
  75. 'password_hash' => Yii::t('app', 'Password Hash'),
  76. 'auth_key' => Yii::t('app', 'Auth Key'),
  77. 'confirmed_at' => Yii::t('app', 'Confirmed At'),
  78. 'unconfirmed_email' => Yii::t('app', 'Unconfirmed Email'),
  79. 'blocked_at' => Yii::t('app', 'Blocked At'),
  80. 'registration_ip' => Yii::t('app', 'Registration Ip'),
  81. 'created_at' => Yii::t('app', 'Created At'),
  82. 'updated_at' => Yii::t('app', 'Updated At'),
  83. 'flags' => Yii::t('app', 'Flags'),
  84. ];
  85. }
  86. /**
  87. * @return \yii\db\ActiveQuery
  88. */
  89. public function getSocialAccounts()
  90. {
  91. return $this->hasMany(SocialAccount::className(), ['user_id' => 'id']);
  92. }
  93. /**
  94. * @return \yii\db\ActiveQuery
  95. */
  96. public function getTokens()
  97. {
  98. return $this->hasMany(Token::className(), ['user_id' => 'id']);
  99. }
  100. }