master
cody 2 weeks ago
parent 43041579a3
commit d297fcb927

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

Loading…
Cancel
Save