|
|
|
|
@ -64,6 +64,16 @@ class CourseContentCheckController extends BaseController
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$all = request()->all();
|
|
|
|
|
// 签到用户
|
|
|
|
|
$courseContentCheck = CourseContentCheck::where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['course_id'])) {
|
|
|
|
|
$query->where('course_id', $all['course_id']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['course_content_id'])) {
|
|
|
|
|
$query->where('course_content_id', $all['course_content_id']);
|
|
|
|
|
}
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
$list = CourseSign::with(['course.typeDetail', 'user'])->whereHas('user', function ($query) use ($all) {
|
|
|
|
|
if (isset($all['name'])) {
|
|
|
|
|
$query->where('name', 'like', '%' . $all['name'] . '%');
|
|
|
|
|
@ -71,10 +81,17 @@ class CourseContentCheckController extends BaseController
|
|
|
|
|
if (isset($all['mobile'])) {
|
|
|
|
|
$query->where('mobile', 'like', '%' . $all['mobile'] . '%');
|
|
|
|
|
}
|
|
|
|
|
})->where(function ($query) use ($all) {
|
|
|
|
|
})->where(function ($query) use ($all, $courseContentCheck) {
|
|
|
|
|
if (isset($all['course_id'])) {
|
|
|
|
|
$query->where('course_id', $all['course_id']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['has_check'])) {
|
|
|
|
|
if ($all['has_check'] == 1) {
|
|
|
|
|
$query->whereIn('user_id', $courseContentCheck->pluck('user_id'));
|
|
|
|
|
} else {
|
|
|
|
|
$query->whereNotIn('user_id', $courseContentCheck->pluck('user_id'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['filter']) && !empty($all['filter'])) {
|
|
|
|
|
foreach ($all['filter'] as $condition) {
|
|
|
|
|
$key = $condition['key'] ?? null;
|
|
|
|
|
@ -111,21 +128,6 @@ class CourseContentCheckController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
|
|
|
|
|
->orderBy('created_at', 'desc');
|
|
|
|
|
if (isset($all['has_check'])) {
|
|
|
|
|
if ($all['has_check'] == 1) {
|
|
|
|
|
$list = $list->whereHas('courseContentCheck', function ($query) use ($all) {
|
|
|
|
|
if (isset($all['course_content_id'])) {
|
|
|
|
|
$query->where('course_content_id', $all['course_content_id']);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$list = $list->whereDoesntHave('courseContentCheck', function ($query) use ($all) {
|
|
|
|
|
if (isset($all['course_content_id'])) {
|
|
|
|
|
$query->where('course_content_id', $all['course_content_id']);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['is_export']) && !empty($all['is_export'])) {
|
|
|
|
|
$list = $list->limit(5000)->get()->toArray();
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
@ -137,9 +139,9 @@ class CourseContentCheckController extends BaseController
|
|
|
|
|
})->first();
|
|
|
|
|
// 是否存在courseContentCheck
|
|
|
|
|
if ($courseContentChecks) {
|
|
|
|
|
$item->course_content_check_text = '已签到';
|
|
|
|
|
$item['course_content_check_text'] = '已签到';
|
|
|
|
|
} else {
|
|
|
|
|
$item->course_content_check_text = '未签到';
|
|
|
|
|
$item['course_content_check_text'] = '未签到';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), $all['file_name'] ?? '' . date('YmdHis') . '.xlsx');
|
|
|
|
|
@ -147,7 +149,7 @@ class CourseContentCheckController extends BaseController
|
|
|
|
|
// 输出
|
|
|
|
|
$list = $list->paginate($all['page_size'] ?? 20);
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
$item->courseContentChecks = CourseContentCheck::where('course_id', $item->course_id)
|
|
|
|
|
$item->course_content_checks = CourseContentCheck::where('course_id', $item->course_id)
|
|
|
|
|
->where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['course_content_id'])) {
|
|
|
|
|
$query->where('course_content_id', $all['course_content_id']);
|
|
|
|
|
|