Curd.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace addons\RfDemo\common\models;
  3. use common\behaviors\MerchantBehavior;
  4. use common\helpers\StringHelper;
  5. /**
  6. * This is the model class for table "{{%addon_demo_curd}}".
  7. *
  8. * @property int $id ID
  9. * @property int|null $merchant_id 商户id
  10. * @property int $member_id 管理员ID
  11. * @property string $title 标题
  12. * @property int|null $cate_id 分类
  13. * @property int|null $sort 排序
  14. * @property int $gender 性别1男2女
  15. * @property string $content 内容
  16. * @property string $tag 标签
  17. * @property string $cover 图片
  18. * @property string $covers 图片组
  19. * @property string $file 文件
  20. * @property string $files 文件组
  21. * @property string $keywords 关键字
  22. * @property string $description 描述
  23. * @property float $price 价格
  24. * @property int $views 点击
  25. * @property int|null $start_time 开始时间
  26. * @property int|null $end_time 结束时间
  27. * @property string|null $email 邮箱
  28. * @property int|null $province_id 省
  29. * @property int|null $city_id 市
  30. * @property int|null $area_id 区
  31. * @property string|null $ip ip
  32. * @property string|null $date 日期
  33. * @property string|null $time 时间
  34. * @property string|null $color 颜色
  35. * @property string|null $longitude 经纬度
  36. * @property string|null $latitude 经纬度
  37. * @property string|null $map_overlay 地图范围
  38. * @property int|null $status 状态
  39. * @property int $created_at 创建时间
  40. * @property int $updated_at 更新时间
  41. */
  42. class Curd extends \common\models\base\BaseModel
  43. {
  44. use MerchantBehavior;
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public static function tableName()
  49. {
  50. return '{{%addon_demo_curd}}';
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function rules()
  56. {
  57. return [
  58. [['title'], 'required'],
  59. [['merchant_id', 'member_id', 'cate_id', 'sort', 'gender', 'views', 'province_id', 'city_id', 'area_id', 'status', 'created_at', 'updated_at'], 'integer'],
  60. [['content', 'covers', 'files'], 'required'],
  61. [['content'], 'string'],
  62. [['covers', 'files', 'date', 'multiple_input', 'cate_ids', 'start_time', 'end_time'], 'safe'],
  63. [['price'], 'number'],
  64. [['title', 'ip'], 'string', 'max' => 50],
  65. [['tag', 'cover', 'file', 'keywords'], 'string', 'max' => 100],
  66. [['description', 'head_portrait'], 'string', 'max' => 200],
  67. [['email'], 'string', 'max' => 60],
  68. [['time'], 'string', 'max' => 20],
  69. [['color'], 'string', 'max' => 7],
  70. [['longitude', 'latitude'], 'string', 'max' => 30],
  71. ];
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function attributeLabels()
  77. {
  78. return [
  79. 'id' => 'ID',
  80. 'merchant_id' => '商户id',
  81. 'member_id' => '管理员ID',
  82. 'title' => '标题',
  83. 'cate_id' => '分类',
  84. 'cate_ids' => '分类组',
  85. 'sort' => '排序',
  86. 'gender' => '性别',
  87. 'head_portrait' => '头像',
  88. 'content' => '内容',
  89. 'tag' => '单选标签',
  90. 'multiple_input' => '多输入框',
  91. 'cover' => '单图',
  92. 'covers' => '多图',
  93. 'file' => '单文件',
  94. 'files' => '多文件',
  95. 'keywords' => '关键字',
  96. 'description' => '描述',
  97. 'price' => '价格',
  98. 'views' => '点击',
  99. 'start_time' => '开始时间',
  100. 'end_time' => '结束时间',
  101. 'email' => '邮箱',
  102. 'province_id' => '省',
  103. 'city_id' => '市',
  104. 'area_id' => '区',
  105. 'ip' => 'ip',
  106. 'date' => '日期',
  107. 'time' => '时间',
  108. 'color' => '颜色',
  109. 'longitude' => '经纬度',
  110. 'latitude' => '经纬度',
  111. 'status' => '状态',
  112. 'created_at' => '创建时间',
  113. 'updated_at' => '更新时间',
  114. ];
  115. }
  116. /**
  117. * @return \yii\db\ActiveQuery
  118. */
  119. public function getCate()
  120. {
  121. return $this->hasOne(Cate::class, ['id' => 'cate_id']);
  122. }
  123. public function beforeSave($insert)
  124. {
  125. $this->start_time = StringHelper::dateToInt($this->start_time);
  126. $this->end_time = StringHelper::dateToInt($this->end_time);
  127. return parent::beforeSave($insert);
  128. }
  129. }
粤ICP备19079148号