|
|
|
@ -70,6 +70,8 @@ class CalendarsController 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())]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 全部事件分页列表按开始时间倒序,同一时间按 ID 倒序保持分页稳定。
|
|
|
|
|
|
|
|
$sortDirection = !$isExport && !empty($all['paginate']) ? 'desc' : 'asc';
|
|
|
|
$query = Calendar::with('course', 'courseContent', 'historyCourses')
|
|
|
|
$query = Calendar::with('course', 'courseContent', 'historyCourses')
|
|
|
|
->where(function ($query) use ($all, $isExport) {
|
|
|
|
->where(function ($query) use ($all, $isExport) {
|
|
|
|
if (!empty($all['start_date']) && !empty($all['end_date'])) {
|
|
|
|
if (!empty($all['start_date']) && !empty($all['end_date'])) {
|
|
|
|
@ -86,8 +88,8 @@ class CalendarsController extends BaseController
|
|
|
|
$query->where($field, $all[$field]);
|
|
|
|
$query->where($field, $all[$field]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})->orderBy('start_time', 'asc')
|
|
|
|
})->orderBy('start_time', $sortDirection)
|
|
|
|
->orderBy('id');
|
|
|
|
->orderBy('id', $sortDirection);
|
|
|
|
// 按需分页,保持月历及现有调用的完整列表结构不变。
|
|
|
|
// 按需分页,保持月历及现有调用的完整列表结构不变。
|
|
|
|
if (!$isExport && !empty($all['paginate'])) {
|
|
|
|
if (!$isExport && !empty($all['paginate'])) {
|
|
|
|
$pageSize = (int) ($all['page_size'] ?? 20);
|
|
|
|
$pageSize = (int) ($all['page_size'] ?? 20);
|
|
|
|
|