123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- use app\model\TrainType;
- class TrainCourse extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'delete_time';
- protected $defaultSoftDelete = 0;
-
- public function getTypeIdAttr($value , $data)
- {
- if (empty($value)) return $value;
-
- $name = TrainType::where(['id'=>$value , 'root_id'=>$data['root_id']])->value('type');
- return $name;
- }
-
- public function getFileAttr($value)
- {
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
- public function getVideoImgAttr($value)
- {
- if (empty($value)) return $value;
- $ali_oss_bindurl = config('app.ali_oss_bindurl');
- $url = 'https://' . $ali_oss_bindurl . '/' . $value;
- return $url;
- }
- public function trainCourseView(){
- return $this->hasMany(TrainCourseView::class, 'con_id', 'id');
- }
- }
|