UserHouse.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%user_house}}".
  6. *
  7. * @property string $id
  8. * @property integer $uid
  9. * @property string $compound
  10. * @property string $layout
  11. * @property string $acreage
  12. * @property string $amount
  13. * @property string $province
  14. * @property string $city
  15. * @property string $district
  16. * @property string $address
  17. * @property integer $created_at
  18. * @property integer $status
  19. * @property integer $updated_at
  20. */
  21. class UserHouse extends \yii\db\ActiveRecord
  22. {
  23. /**
  24. * @inheritdoc
  25. */
  26. const STATUS_DELETED = 0;
  27. const STATUS_ACTIVE = 10;
  28. public static function tableName()
  29. {
  30. return '{{%user_house}}';
  31. }
  32. /**
  33. * @inheritdoc
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['uid', 'created_at', 'status', 'updated_at'], 'integer'],
  39. [['compound', 'layout', 'acreage', 'province', 'city', 'district'], 'string', 'max' => 32],
  40. [['amount'], 'string', 'max' => 10],
  41. [['address','style'], 'string', 'max' => 255],
  42. [['status'], 'default', 'value' => self::STATUS_ACTIVE],
  43. [['created_at','updated_at'], 'default', 'value' => time()],
  44. [['uid'], 'default', 'value' => Yii::$app->user->id],
  45. ];
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'id' => 'ID',
  54. 'uid' => 'Uid',
  55. 'compound' => '小区名称',
  56. 'layout' => '户型',
  57. 'acreage' => '面积',
  58. 'amount' => '预算',
  59. 'province' => '省份',
  60. 'city' => '城市',
  61. 'district' => '地区',
  62. 'address' => '详细地址',
  63. 'created_at' => '创建时间',
  64. 'status' => '状态',
  65. 'style' => '装修风格',
  66. 'updated_at' => 'Updated At',
  67. ];
  68. }
  69. public function getUserinfo(){
  70. return $this->hasOne(User::className(),['id'=>'uid']);
  71. }
  72. public function getNickname(){
  73. return $this->hasOne(UserInfo::className(),['uid'=>'uid']);
  74. }
  75. }