VideoTutorialsLog.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace common\models\backend;
  3. use common\models\base\BaseActiveRecord;
  4. /**
  5. * This is the model class for table "qimall_video_tutorials_log".
  6. *
  7. * @property int $id
  8. * @property int $admin_id 账户id
  9. * @property int $video_tutorials_id 视频教程id
  10. * @property int $is_complete 是否完整观看;1:是;0否
  11. * @property int $view_times 浏览时长
  12. * @property int $created_at
  13. * @property int $updated_at
  14. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  15. */
  16. class VideoTutorialsLog extends BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%video_tutorials_log}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['admin_id', 'video_tutorials_id', 'is_complete', 'view_times', 'created_at', 'updated_at', 'status'], 'integer'],
  32. ];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'admin_id' => '账户id',
  42. 'video_tutorials_id' => '视频教程id',
  43. 'is_complete' => '是否完整观看;1:是;0否',
  44. 'view_times' => '浏览时长',
  45. 'created_at' => 'Created At',
  46. 'updated_at' => 'Updated At',
  47. 'status' => '状态[-1:删除;0:禁用;1启用]',
  48. ];
  49. }
  50. public static function addVideoTutorialsLog($params)
  51. {
  52. try {
  53. $model = new self();
  54. $model->loadDefaultValues();
  55. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  56. return $model;
  57. } catch (\Exception $e) {
  58. self::$static_error = $e->getMessage();
  59. return false;
  60. }
  61. }
  62. }