|
|
|
|
@ -49,16 +49,13 @@ class CalendarsController extends BaseController
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'month.required' => '月份必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'month' => 'required',
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
$list = Calendar::with('course', 'courseContent')->where('start_time', 'like', $all['month'] . '%')->orderBy('date')->get();
|
|
|
|
|
$list = Calendar::with('course', 'courseContent')
|
|
|
|
|
->where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['month'])) {
|
|
|
|
|
$query->where('start_time', 'like', $all['month'] . '%');
|
|
|
|
|
}
|
|
|
|
|
})->orderBy('date')
|
|
|
|
|
->get();
|
|
|
|
|
if (isset($all['is_export']) && $all['is_export'] == 1) {
|
|
|
|
|
$list = $list->toArray();
|
|
|
|
|
return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), ($all['file_name'] ?? '') . date('YmdHis') . '.xlsx');
|
|
|
|
|
|