|
|
|
@ -137,43 +137,44 @@ class CompanyController extends BaseController
|
|
|
|
})->with('courseSigns.course');
|
|
|
|
})->with('courseSigns.course');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->whereHas('users', function ($query) use ($all) {
|
|
|
|
])->whereHas('users', function ($query) use ($all) {
|
|
|
|
if (isset($all['course_type_id']) && !empty($all['course_type_id'])) {
|
|
|
|
// 课程筛选:与 courses-home / getStudentList 口径一致,仅 status=1 的报名,且由同一条 courseSign 满足 type/name/日期/is_chart
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
$hasCourseFilter = (isset($all['course_type_id']) && $all['course_type_id'] !== '') ||
|
|
|
|
$q->where('type', $all['course_type_id']);
|
|
|
|
(isset($all['course_name']) && $all['course_name'] !== '') ||
|
|
|
|
});
|
|
|
|
(isset($all['course_start_date']) && $all['course_start_date'] !== '') ||
|
|
|
|
}
|
|
|
|
(isset($all['course_end_date']) && $all['course_end_date'] !== '') ||
|
|
|
|
if (isset($all['course_name']) && !empty($all['course_name'])) {
|
|
|
|
(isset($all['is_chart']) && $all['is_chart'] !== '');
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
|
|
|
|
$q->where('name', 'like', '%' . $all['course_name'] . '%');
|
|
|
|
if ($hasCourseFilter) {
|
|
|
|
});
|
|
|
|
$query->whereHas('courseSigns', function ($q) use ($all) {
|
|
|
|
}
|
|
|
|
$q->where('status', 1);
|
|
|
|
// 课程起止时间筛选
|
|
|
|
$q->whereHas('course', function ($c) use ($all) {
|
|
|
|
if (
|
|
|
|
if (isset($all['course_type_id']) && $all['course_type_id'] !== '') {
|
|
|
|
(isset($all['course_start_date']) && !empty($all['course_start_date'])) ||
|
|
|
|
$c->where('type', $all['course_type_id']);
|
|
|
|
(isset($all['course_end_date']) && !empty($all['course_end_date']))
|
|
|
|
}
|
|
|
|
) {
|
|
|
|
if (isset($all['course_name']) && $all['course_name'] !== '') {
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
$c->where('name', 'like', '%' . $all['course_name'] . '%');
|
|
|
|
$course_start_date = $all['course_start_date'] ?? null;
|
|
|
|
}
|
|
|
|
$course_end_date = $all['course_end_date'] ?? null;
|
|
|
|
if (
|
|
|
|
if ($course_start_date && $course_end_date) {
|
|
|
|
(isset($all['course_start_date']) && $all['course_start_date'] !== '') ||
|
|
|
|
// 课程开始时间或结束时间在指定时间范围内
|
|
|
|
(isset($all['course_end_date']) && $all['course_end_date'] !== '')
|
|
|
|
$q->where(function ($subQuery) use ($course_start_date, $course_end_date) {
|
|
|
|
) {
|
|
|
|
$subQuery->whereBetween('start_date', [$course_start_date, $course_end_date])
|
|
|
|
$course_start_date = $all['course_start_date'] ?? null;
|
|
|
|
->orWhereBetween('end_date', [$course_start_date, $course_end_date]);
|
|
|
|
$course_end_date = $all['course_end_date'] ?? null;
|
|
|
|
});
|
|
|
|
if ($course_start_date && $course_end_date) {
|
|
|
|
} elseif ($course_start_date) {
|
|
|
|
$c->where(function ($sub) use ($course_start_date, $course_end_date) {
|
|
|
|
// 只指定开始日期,筛选课程结束时间 >= 开始日期
|
|
|
|
$sub->whereBetween('start_date', [$course_start_date, $course_end_date])
|
|
|
|
$q->where('end_date', '>=', $course_start_date);
|
|
|
|
->orWhereBetween('end_date', [$course_start_date, $course_end_date]);
|
|
|
|
} elseif ($course_end_date) {
|
|
|
|
});
|
|
|
|
// 只指定结束日期,筛选课程开始时间 <= 结束日期
|
|
|
|
} elseif ($course_start_date) {
|
|
|
|
$q->where('start_date', '<=', $course_end_date);
|
|
|
|
$c->where('end_date', '>=', $course_start_date);
|
|
|
|
}
|
|
|
|
} elseif ($course_end_date) {
|
|
|
|
});
|
|
|
|
$c->where('start_date', '<=', $course_end_date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 课程是否参与统计:0否 1是(按公司下用户关联的课程的 is_chart 筛选)
|
|
|
|
}
|
|
|
|
if (isset($all['is_chart']) && $all['is_chart'] !== '') {
|
|
|
|
if (isset($all['is_chart']) && $all['is_chart'] !== '') {
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
$c->where('is_chart', $all['is_chart']);
|
|
|
|
$q->where('is_chart', $all['is_chart']);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['user_name']) && !empty($all['user_name'])) {
|
|
|
|
if (isset($all['user_name']) && !empty($all['user_name'])) {
|
|
|
|
|