| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * -模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
- class VideoCoursesModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'videos_courses';
- <<<<<<< HEAD
- =======
- public function getPosterAttribute($value)
- {
- return $value? get_image_url($value) : '';
- }
- public function setPosterAttribute($value)
- {
- return $value? get_image_path($value) : '';
- }
- public function getFeeAttribute($value)
- {
- return $value? floatval($value) : 0.00;
- }
- /**
- * 课程集
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function collection()
- {
- return $this->hasOne(VideoModel::class, 'id', 'video_id')
- ->with(['category'])
- ->where(['status'=>1,'mark'=>1])
- ->select(['id', 'video_name', 'category_id','type','poster','description', 'status']);
- }
- /**
- * 是否有效购买单集VIP
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function vip()
- {
- return $this->hasOne(VideoOrderModel::class, 'goods_id', 'id')
- ->where('expired_at','>', date('Y-m-d H:i:s'))
- ->where(['status'=>2,'mark'=>1])
- ->select(['id', 'order_no', 'goods_id','total','expired_at', 'status']);
- }
- /**
- * 所有课程
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function courses()
- {
- return $this->hasMany(VideoCoursesModel::class, 'video_id', 'video_id')
- ->where(['status'=>1,'mark'=>1]);
- }
- /**
- * 学习记录
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function learns()
- {
- return $this->hasMany(VideoLearnLogModel::class, 'video_id', 'video_id')
- ->where(['status'=>1,'mark'=>1]);
- }
- >>>>>>> d64ac277db90f4649e277b9e40eb3d141ae8c846
- }
|