|
|
@ -29,13 +29,21 @@ class Course extends Controller |
|
|
|
->when($courseCategoryId, function ($query) use ($courseCategoryId) { |
|
|
|
->when($courseCategoryId, function ($query) use ($courseCategoryId) { |
|
|
|
return $query->where('course_category_id', $courseCategoryId)->where('status', 1); |
|
|
|
return $query->where('course_category_id', $courseCategoryId)->where('status', 1); |
|
|
|
})->paginate($pageSize); |
|
|
|
})->paginate($pageSize); |
|
|
|
|
|
|
|
|
|
|
|
if(empty($list)){ |
|
|
|
if(empty($list)){ |
|
|
|
return $this->renderError("没有课程"); |
|
|
|
return $this->renderError("没有课程"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$image_ids = array_column(($list->toArray())['data'], 'image_id'); |
|
|
|
|
|
|
|
$video_ids = array_column(($list->toArray())['data'], 'video_id'); |
|
|
|
|
|
|
|
$images= array_unique(array_merge($image_ids,$video_ids)); |
|
|
|
|
|
|
|
$image = UploadFile::withoutGlobalScope()->whereIn('file_id',$images)->select(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list_image = array_column($image->toArray(), null ,'file_id'); |
|
|
|
|
|
|
|
|
|
|
|
foreach($list as $value){ |
|
|
|
foreach($list as $value){ |
|
|
|
$value['image_url'] = UploadFile::withoutGlobalScope()->where('file_id', '=',$value['image_id'])->find(); |
|
|
|
$value['image_url'] = $list_image[$value['image_id']] ?? []; |
|
|
|
$value['video_url'] = UploadFile::withoutGlobalScope()->where('file_id', '=',$value['video_id'])->find(); |
|
|
|
$value['video_url'] = $list_image[$value['video_id']] ?? []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|