Design.php 1.3 KB

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