删除学员课程不统计

master
lion 4 days ago
parent 760134fc22
commit 9024174feb

@ -60,7 +60,7 @@ class CourseController extends BaseController
$list = $this->model->with(underlineToHump($all['show_relation'] ?? [])) $list = $this->model->with(underlineToHump($all['show_relation'] ?? []))
->withCount([ ->withCount([
'courseSigns' => function ($query) { 'courseSigns' => function ($query) {
$query->whereNotIn('status', [4, 5]); $query->whereNotIn('status', [4, 5])->whereHas('user');
} }
])->withCount([ ])->withCount([
'courseSigns as sign_pass_total' => function ($query) { 'courseSigns as sign_pass_total' => function ($query) {
@ -258,7 +258,11 @@ class CourseController extends BaseController
if ($validator->fails()) { if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
} }
$detail = $this->model->withCount('courseSigns')->with(underlineToHump($all['show_relation'] ?? []))->find($all['id']); $detail = $this->model->withCount([
'courseSigns' => function ($query) {
$query->whereHas('user');
}
])->with(underlineToHump($all['show_relation'] ?? []))->find($all['id']);
if ($detail) { if ($detail) {
$detail->setAppends(array_values(array_diff($detail->getAppends(), ['qrcode']))); $detail->setAppends(array_values(array_diff($detail->getAppends(), ['qrcode'])));
} }

@ -98,6 +98,7 @@ class OtherController extends CommonController
$courseIds = Course::where('type', $courseType->id)->pluck('id'); $courseIds = Course::where('type', $courseType->id)->pluck('id');
$courseType->course_signs_total = CourseSign::whereIn('course_id', $courseIds) $courseType->course_signs_total = CourseSign::whereIn('course_id', $courseIds)
->where('status', 1) ->where('status', 1)
->whereHas('user')
->count(); ->count();
} }
// 苏州区域数据 // 苏州区域数据

@ -98,7 +98,7 @@ class CourseSign extends SoftDeletesModel
->orWhereBetween('end_date', [$start_date, $end_date]); ->orWhereBetween('end_date', [$start_date, $end_date]);
}); });
} }
})->whereNotIn('status', [4, 5, 6]); })->whereHas('user')->whereNotIn('status', [4, 5, 6]);
return $baseQuery; return $baseQuery;
} }

Loading…
Cancel
Save