VideoCoursesModel_BACKUP_1590.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * -模型
  14. * @author laravel开发员
  15. * @since 2020/11/11
  16. * @package App\Models
  17. */
  18. class VideoCoursesModel extends BaseModel
  19. {
  20. // 设置数据表
  21. protected $table = 'videos_courses';
  22. <<<<<<< HEAD
  23. =======
  24. public function getPosterAttribute($value)
  25. {
  26. return $value? get_image_url($value) : '';
  27. }
  28. public function setPosterAttribute($value)
  29. {
  30. return $value? get_image_path($value) : '';
  31. }
  32. public function getFeeAttribute($value)
  33. {
  34. return $value? floatval($value) : 0.00;
  35. }
  36. /**
  37. * 课程集
  38. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  39. */
  40. public function collection()
  41. {
  42. return $this->hasOne(VideoModel::class, 'id', 'video_id')
  43. ->with(['category'])
  44. ->where(['status'=>1,'mark'=>1])
  45. ->select(['id', 'video_name', 'category_id','type','poster','description', 'status']);
  46. }
  47. /**
  48. * 是否有效购买单集VIP
  49. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  50. */
  51. public function vip()
  52. {
  53. return $this->hasOne(VideoOrderModel::class, 'goods_id', 'id')
  54. ->where('expired_at','>', date('Y-m-d H:i:s'))
  55. ->where(['status'=>2,'mark'=>1])
  56. ->select(['id', 'order_no', 'goods_id','total','expired_at', 'status']);
  57. }
  58. /**
  59. * 所有课程
  60. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  61. */
  62. public function courses()
  63. {
  64. return $this->hasMany(VideoCoursesModel::class, 'video_id', 'video_id')
  65. ->where(['status'=>1,'mark'=>1]);
  66. }
  67. /**
  68. * 学习记录
  69. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  70. */
  71. public function learns()
  72. {
  73. return $this->hasMany(VideoLearnLogModel::class, 'video_id', 'video_id')
  74. ->where(['status'=>1,'mark'=>1]);
  75. }
  76. >>>>>>> d64ac277db90f4649e277b9e40eb3d141ae8c846
  77. }