Offer.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%offer}}".
  6. *
  7. * @property integer $id
  8. * @property string $nickname
  9. * @property string $tel
  10. * @property string $area_id
  11. * @property string $acreage
  12. * @property string $layout
  13. * * @property integer $c_time
  14. * * @property integer $status
  15. */
  16. class Offer extends \yii\db\ActiveRecord
  17. {
  18. /**
  19. * @inheritdoc
  20. */
  21. const STATUS_YES = 10;
  22. const STATUS_NO = 0;
  23. public static function tableName()
  24. {
  25. return '{{%offer}}';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['c_time'], 'default','value'=>time()],
  34. [['status'], 'default','value'=>self::STATUS_YES],
  35. [['nickname','tel','area_id'],'required'],
  36. [['nickname'], 'string','max' => 32],
  37. [['c_time','status'], 'integer'],
  38. ];
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'nickname' => '昵称',
  48. 'tel' => '手机号',
  49. 'area_id' => '城市编号',
  50. 'acreage' => '房屋面积',
  51. 'layout' => '户型',
  52. 'c_time' => '创建时间',
  53. 'status' => '状态',
  54. ];
  55. }
  56. public function getCity(){
  57. return $this->hasOne(Area::className(),['area_id'=>'area_id'])->select("area");
  58. }
  59. }