Profile.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace common\modules\user\models;
  3. use common\models\Voice;
  4. use common\modules\attachment\behaviors\UploadBehavior;
  5. use common\modules\attachment\models\Attachment;
  6. use Yii;
  7. use yii\behaviors\TimestampBehavior;
  8. /**
  9. * This is the model class for table "{{%user_profile}}".
  10. *
  11. * @property integer $id
  12. * @property integer $money
  13. * @property integer $integral
  14. * @property integer $created_at
  15. * @property integer $updated_at
  16. * @property string $signature
  17. * @property string $avatar
  18. * @property integer $gender
  19. * @property string $country
  20. * @property string $province
  21. * @property string $city
  22. * @property string $address
  23. * @property string $contact
  24. * @property array $genderList
  25. *
  26. */
  27. class Profile extends \yii\db\ActiveRecord
  28. {
  29. /**
  30. * @inheritdoc
  31. */
  32. public static function tableName()
  33. {
  34. return '{{%user_profile}}';
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function rules()
  40. {
  41. return [
  42. [['gender'], 'integer'],
  43. [['money', 'integral'], 'integer'], // 充值场景
  44. [['signature'], 'string', 'max' => 100],
  45. [['province', 'city', 'country'], 'string', 'max' => 50],
  46. ['locale', 'default', 'value' => Yii::$app->language],
  47. // ['locale', 'in', 'range' => array_keys(self::getLocaleList())],
  48. [['picture', 'avatar', 'rank_pic'], 'safe']
  49. ];
  50. }
  51. /**
  52. * @inheritdoc
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'money' => Yii::t('common', '余额'),
  59. 'integral' => Yii::t('common', '积分'),
  60. 'created_at' => Yii::t('common', 'Created At'),
  61. 'updated_at' => Yii::t('common', 'Updated At'),
  62. 'signature' => Yii::t('common', 'Signature'),
  63. 'avatar' => Yii::t('common', 'Avatar'),
  64. 'gender' => Yii::t('common', 'Gender'),
  65. 'locale' => '语言',
  66. 'province' => '省份',
  67. 'city' => '市县',
  68. 'address' => '地址',
  69. 'contact' => '联系人',
  70. 'country' => '国家',
  71. ];
  72. }
  73. public function behaviors()
  74. {
  75. return [
  76. TimestampBehavior::className(),
  77. // [
  78. // 'class' => UploadBehavior::className(),
  79. // 'attribute' => 'avatar',
  80. // 'entity' => __CLASS__
  81. // ],
  82. ];
  83. }
  84. public static function getGenderList()
  85. {
  86. return [Yii::t('common', 'Male'), Yii::t('common', 'Famale')];
  87. }
  88. public static function getLocaleList()
  89. {
  90. return [
  91. 'zh-CN' => '简体中文'
  92. ];
  93. }
  94. /**
  95. * @return string
  96. */
  97. public function getFullArea()
  98. {
  99. return $this->country . ' ' . $this->province . ' ' . $this->city;
  100. }
  101. public function afterFind()
  102. {
  103. parent::afterFind(); // TODO: Change the autogenerated stub
  104. }
  105. }