|
|
|
@ -63,102 +63,109 @@ class CourseController extends BaseController
|
|
|
|
$query->whereNotIn('status', [4, 5]);
|
|
|
|
$query->whereNotIn('status', [4, 5]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_pass_total' => function ($query) {
|
|
|
|
'courseSigns as sign_pass_total' => function ($query) {
|
|
|
|
$query->where('status', 1)->whereHas('user');
|
|
|
|
$query->where('status', 1)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_wait_total' => function ($query) {
|
|
|
|
'courseSigns as sign_wait_total' => function ($query) {
|
|
|
|
$query->where('status', 0)->whereHas('user');
|
|
|
|
$query->where('status', 0)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_fault_total' => function ($query) {
|
|
|
|
'courseSigns as sign_fault_total' => function ($query) {
|
|
|
|
$query->where('status', 2)->whereHas('user');
|
|
|
|
$query->where('status', 2)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_prepare_total' => function ($query) {
|
|
|
|
'courseSigns as sign_prepare_total' => function ($query) {
|
|
|
|
$query->where('status', 3)->whereHas('user');
|
|
|
|
$query->where('status', 3)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_cancel_total' => function ($query) {
|
|
|
|
'courseSigns as sign_cancel_total' => function ($query) {
|
|
|
|
$query->where('status', 4)->whereHas('user');
|
|
|
|
$query->where('status', 4)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_give_up_total' => function ($query) {
|
|
|
|
'courseSigns as sign_give_up_total' => function ($query) {
|
|
|
|
$query->where('status', 5)->whereHas('user');
|
|
|
|
$query->where('status', 5)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->withCount([
|
|
|
|
])->withCount([
|
|
|
|
'courseSigns as sign_black_total' => function ($query) {
|
|
|
|
'courseSigns as sign_black_total' => function ($query) {
|
|
|
|
$query->where('status', 6)->whereHas('user');
|
|
|
|
$query->where('status', 6)->whereHas('user');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->where(function ($query) use ($all) {
|
|
|
|
])->where(function ($query) use ($all) {
|
|
|
|
if (isset($all['has_course_forms']) && !empty($all['has_course_forms'])) {
|
|
|
|
if (isset($all['has_course_forms']) && !empty($all['has_course_forms'])) {
|
|
|
|
$query->whereHas('courseForms');
|
|
|
|
$query->whereHas('courseForms');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['start_date'])) {
|
|
|
|
if (isset($all['start_date'])) {
|
|
|
|
$query->where('start_date', '>=', $all['start_date']);
|
|
|
|
$query->where('start_date', '>=', $all['start_date']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['end_date'])) {
|
|
|
|
if (isset($all['end_date'])) {
|
|
|
|
$query->where('end_date', '<=', $all['end_date']);
|
|
|
|
$query->where('end_date', '<=', $all['end_date']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['course_type_id'])) {
|
|
|
|
if (isset($all['course_type_id'])) {
|
|
|
|
$course_type_id = explode(',', $all['course_type_id']);
|
|
|
|
$course_type_id = explode(',', $all['course_type_id']);
|
|
|
|
$query->whereIn('type', $course_type_id);
|
|
|
|
$query->whereIn('type', $course_type_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['filter']) && !empty($all['filter'])) {
|
|
|
|
if (isset($all['filter']) && !empty($all['filter'])) {
|
|
|
|
foreach ($all['filter'] as $condition) {
|
|
|
|
foreach ($all['filter'] as $condition) {
|
|
|
|
$key = $condition['key'] ?? null;
|
|
|
|
$key = $condition['key'] ?? null;
|
|
|
|
$op = $condition['op'] ?? null;
|
|
|
|
$op = $condition['op'] ?? null;
|
|
|
|
$value = $condition['value'] ?? null;
|
|
|
|
$value = $condition['value'] ?? null;
|
|
|
|
if (!isset($key) || !isset($op) || !isset($value)) {
|
|
|
|
if (!isset($key) || !isset($op) || !isset($value)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($key == 'start_date') {
|
|
|
|
|
|
|
|
list($from, $to) = explode(',', $value);
|
|
|
|
|
|
|
|
$query->where(function ($q) use ($from, $to) {
|
|
|
|
|
|
|
|
$q->whereBetween('start_date', [$from, $to])->orWhereBetween('end_date', [$from, $to]);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 等于
|
|
|
|
|
|
|
|
if ($op == 'eq') {
|
|
|
|
|
|
|
|
$query->where($key, $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 不等于
|
|
|
|
|
|
|
|
if ($op == 'neq') {
|
|
|
|
|
|
|
|
$query->where($key, '!=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 大于
|
|
|
|
|
|
|
|
if ($op == 'gt') {
|
|
|
|
|
|
|
|
$query->where($key, '>', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 大于等于
|
|
|
|
|
|
|
|
if ($op == 'egt') {
|
|
|
|
|
|
|
|
$query->where($key, '>=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 小于
|
|
|
|
|
|
|
|
if ($op == 'lt') {
|
|
|
|
|
|
|
|
$query->where($key, '<', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 小于等于
|
|
|
|
|
|
|
|
if ($op == 'elt') {
|
|
|
|
|
|
|
|
$query->where($key, '<=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 模糊搜索
|
|
|
|
|
|
|
|
if ($op == 'like') {
|
|
|
|
|
|
|
|
$query->where($key, 'like', '%' . $value . '%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 否定模糊搜索
|
|
|
|
|
|
|
|
if ($op == 'notlike') {
|
|
|
|
|
|
|
|
$query->where($key, 'not like', '%' . $value . '%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 范围搜索
|
|
|
|
|
|
|
|
if ($op == 'range') {
|
|
|
|
|
|
|
|
list($from, $to) = explode(',', $value);
|
|
|
|
|
|
|
|
if (empty($from) || empty($to)) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 等于
|
|
|
|
$query->whereBetween($key, [$from, $to]);
|
|
|
|
if ($op == 'eq') {
|
|
|
|
}
|
|
|
|
$query->where($key, $value);
|
|
|
|
if ($op == 'in') {
|
|
|
|
}
|
|
|
|
$array = explode(',', $value);
|
|
|
|
// 不等于
|
|
|
|
$query->whereIn($key, $array);
|
|
|
|
if ($op == 'neq') {
|
|
|
|
|
|
|
|
$query->where($key, '!=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 大于
|
|
|
|
|
|
|
|
if ($op == 'gt') {
|
|
|
|
|
|
|
|
$query->where($key, '>', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 大于等于
|
|
|
|
|
|
|
|
if ($op == 'egt') {
|
|
|
|
|
|
|
|
$query->where($key, '>=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 小于
|
|
|
|
|
|
|
|
if ($op == 'lt') {
|
|
|
|
|
|
|
|
$query->where($key, '<', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 小于等于
|
|
|
|
|
|
|
|
if ($op == 'elt') {
|
|
|
|
|
|
|
|
$query->where($key, '<=', $value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 模糊搜索
|
|
|
|
|
|
|
|
if ($op == 'like') {
|
|
|
|
|
|
|
|
$query->where($key, 'like', '%' . $value . '%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 否定模糊搜索
|
|
|
|
|
|
|
|
if ($op == 'notlike') {
|
|
|
|
|
|
|
|
$query->where($key, 'not like', '%' . $value . '%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 范围搜索
|
|
|
|
|
|
|
|
if ($op == 'range') {
|
|
|
|
|
|
|
|
list($from, $to) = explode(',', $value);
|
|
|
|
|
|
|
|
if (empty($from) || empty($to)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$query->whereBetween($key, [$from, $to]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($op == 'in') {
|
|
|
|
|
|
|
|
$array = explode(',', $value);
|
|
|
|
|
|
|
|
$query->whereIn($key, $array);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
$list = $list->orderBy($all['sort_name'] ?? 'sign_status', $all['sort_type'] ?? 'asc');
|
|
|
|
$list = $list->orderBy($all['sort_name'] ?? 'sign_status', $all['sort_type'] ?? 'asc');
|
|
|
|
if (isset($all['is_export']) && !empty($all['is_export'])) {
|
|
|
|
if (isset($all['is_export']) && !empty($all['is_export'])) {
|
|
|
|
$list = $list->limit(5000)->get()->toArray();
|
|
|
|
$list = $list->limit(5000)->get()->toArray();
|
|
|
|
|