ShortVideoBrowse.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace addons\ShortVideo\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "{{%addons_short_video_browse}}".
  7. *
  8. * @property int $id
  9. * @property int $mall_id
  10. * @property int $video_id 视频id
  11. * @property int $user_id 用户id
  12. * @property int $is_share 是否分享观看 0:否 1:是
  13. * @property int $is_complete_look 是否完整观看0:否 1:是
  14. * @property int $complete_time 完整观看时间
  15. * @property int $status 状态[-1:删除;0:禁用;1启用]
  16. * @property int $created_at
  17. * @property int $updated_at
  18. */
  19. class ShortVideoBrowse extends \common\models\base\BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return '{{%addons_short_video_browse}}';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'video_id', 'user_id'], 'required'],
  35. [['mall_id', 'video_id', 'user_id', 'is_share', 'is_complete_look', 'complete_time', 'status', 'created_at', 'updated_at'], 'integer'],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'mall_id' => '商城ID',
  46. 'video_id' => '视频ID',
  47. 'user_id' => '会员ID',
  48. 'is_share' => '是否分享观看',
  49. 'is_complete_look' => '是否完整观看',
  50. 'complete_time' => '完整观看时间',
  51. 'status' => '状态[-1:删除;0:禁用;1启用]',
  52. 'created_at' => 'Created At',
  53. 'updated_at' => 'Updated At',
  54. ];
  55. }
  56. public static function setData(int $mall_id, array $data)
  57. {
  58. $model = new self();
  59. $model->loadDefaultValues();
  60. $model->mall_id = $mall_id;
  61. foreach ($data as $key => $val) {
  62. $model->$key = $val;
  63. }
  64. // dd($model);
  65. if (!$model->save()) {
  66. self::$static_error = '保存数据失败:' . $model->getErrorMessage();
  67. return false;
  68. }
  69. return $model;
  70. }
  71. }