|
|
|
@ -233,13 +233,31 @@ class OtherController extends CommonController
|
|
|
|
$calendar = Calendar::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
$calendar = Calendar::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
$query->whereBetween('start_time', [$start_date, $end_date])
|
|
|
|
$query->whereBetween('start_time', [$start_date, $end_date])
|
|
|
|
->orWhereBetween('end_time', [$start_date, $end_date]);
|
|
|
|
->orWhereBetween('end_time', [$start_date, $end_date]);
|
|
|
|
})->where(function ($query) {
|
|
|
|
})->where(function ($query) use ($course_type_id, $courses) {
|
|
|
|
$course_type_id = request('course_type_id');
|
|
|
|
// course_type_id 和 course id 是或关系,满足其中一个就行
|
|
|
|
|
|
|
|
$hasCondition = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 条件1:course_type_id 筛选
|
|
|
|
if ($course_type_id) {
|
|
|
|
if ($course_type_id) {
|
|
|
|
$course_type_id = explode(',', $course_type_id);
|
|
|
|
$course_type_id_array = is_array($course_type_id) ? $course_type_id : explode(',', $course_type_id);
|
|
|
|
$query->whereIn('course_type_id', $course_type_id);
|
|
|
|
$query->whereIn('course_type_id', $course_type_id_array);
|
|
|
|
|
|
|
|
$hasCondition = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 条件2:course id 筛选(或关系)
|
|
|
|
|
|
|
|
if ($courses && $courses->count() > 0) {
|
|
|
|
|
|
|
|
if ($hasCondition) {
|
|
|
|
|
|
|
|
$query->orWhereHas('course', function ($q) use ($courses) {
|
|
|
|
|
|
|
|
$q->whereIn('id', $courses->pluck('id'));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$query->whereHas('course', function ($q) use ($courses) {
|
|
|
|
|
|
|
|
$q->whereIn('id', $courses->pluck('id'));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
|
|
$list['course_total'] = (clone $calendar)->count();
|
|
|
|
$list['course_total'] = (clone $calendar)->count();
|
|
|
|
// 开课天数
|
|
|
|
// 开课天数
|
|
|
|
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
|
|
|
|
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
|
|
|
|
|