Adv.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace addons\TinyBlog\common\models;
  3. use common\behaviors\MerchantStoreBehavior;
  4. use common\helpers\StringHelper;
  5. /**
  6. * This is the model class for table "{{%addon_tiny_blog_adv}}".
  7. *
  8. * @property int $id 序号
  9. * @property int|null $merchant_id 商户id
  10. * @property int|null $store_id 店铺id
  11. * @property string $name 标题
  12. * @property string|null $cover 图片
  13. * @property int|null $location_id 广告位ID
  14. * @property string|null $silder_text 图片描述
  15. * @property int|null $start_time 开始时间
  16. * @property int|null $end_time 结束时间
  17. * @property string|null $jump_link 跳转链接
  18. * @property int|null $jump_type 跳转方式[1:新标签; 2:当前页]
  19. * @property int|null $sort 优先级
  20. * @property int|null $status 状态
  21. * @property int $created_at 创建时间
  22. * @property int $updated_at 更新时间
  23. */
  24. class Adv extends \common\models\base\BaseModel
  25. {
  26. use MerchantStoreBehavior;
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public static function tableName()
  31. {
  32. return '{{%addon_tiny_blog_adv}}';
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['merchant_id', 'store_id', 'location_id', 'jump_type', 'sort', 'status', 'created_at', 'updated_at'], 'integer'],
  41. [['name'], 'string', 'max' => 30],
  42. [['name', 'start_time', 'end_time'], 'required'],
  43. [['start_time', 'end_time'], 'safe'],
  44. [['cover'], 'string', 'max' => 100],
  45. [['silder_text'], 'string', 'max' => 150],
  46. [['jump_link'], 'string', 'max' => 255],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => '序号',
  56. 'merchant_id' => '商户id',
  57. 'store_id' => '店铺id',
  58. 'name' => '标题',
  59. 'cover' => '图片',
  60. 'location_id' => '广告位ID',
  61. 'silder_text' => '图片描述',
  62. 'start_time' => '开始时间',
  63. 'end_time' => '结束时间',
  64. 'jump_link' => '跳转链接',
  65. 'jump_type' => '跳转方式', // [1:新标签; 2:当前页]
  66. 'sort' => '优先级',
  67. 'status' => '状态',
  68. 'created_at' => '创建时间',
  69. 'updated_at' => '更新时间',
  70. ];
  71. }
  72. /**
  73. * @param bool $insert
  74. * @return bool
  75. */
  76. public function beforeSave($insert)
  77. {
  78. $this->start_time = StringHelper::dateToInt($this->start_time);
  79. $this->end_time = StringHelper::dateToInt($this->end_time);
  80. return parent::beforeSave($insert);
  81. }
  82. }
粤ICP备19079148号