删除学员课程不统计

master
lion 18 hours ago
parent 760134fc22
commit 9024174feb

@ -60,7 +60,7 @@ class CourseController extends BaseController
$list = $this->model->with(underlineToHump($all['show_relation'] ?? []))
->withCount([
'courseSigns' => function ($query) {
$query->whereNotIn('status', [4, 5]);
$query->whereNotIn('status', [4, 5])->whereHas('user');
}
])->withCount([
'courseSigns as sign_pass_total' => function ($query) {
@ -258,7 +258,11 @@ class CourseController extends BaseController
if ($validator->fails()) {
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) {
$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');
$courseType->course_signs_total = CourseSign::whereIn('course_id', $courseIds)
->where('status', 1)
->whereHas('user')
->count();
}
// 苏州区域数据

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

Loading…
Cancel
Save