SoldierVideoWatchModel.php 723 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\model;
  3. class SoldierVideoWatchModel extends BaseModel
  4. {
  5. // 设置表名
  6. protected $name = 'soldier_video_watch';
  7. protected $autoWriteTimestamp = true;
  8. // 常量
  9. const STATUS = [1 => '未开始', 2 => '未看完', 3 => '已完成'];
  10. const STATUS_NO_STARTED = 1;
  11. const STATUS_NO_FINISHED = 2;
  12. const STATUS_FINISH = 3;
  13. public function getStatusTextAttr($value, $data)
  14. {
  15. return self::STATUS[$data['status']];
  16. }
  17. public function user()
  18. {
  19. return $this->hasOne(SoldierModel::class, 'id', 'user_id');
  20. }
  21. public function video()
  22. {
  23. return $this->hasOne(SoldierVideoModel::class, 'id', 'video_id');
  24. }
  25. }