where([ "unique_identification" => "annual_session" ])->first(); try { $updateInfo = AdmissionNewStudents::query()->where([ "annual_session" => $input["year"] ])->update([ "annual_session" => $config->data, "is_new_student" => AdmissionNewStudents::IS_NEW_STUDENT_NO, "old_student_bed_info" => "请与辅导员联系", "update_time" => time(), ]); if(empty($updateInfo)){ throw new \Exception("修改失败"); } //dcat-2.0版本写法 return $this->response() ->success('修改成功') ->redirect('/admission_new_students'); } catch (ValidationException $validationException) { return Response::withException($validationException); } catch (Throwable $throwable) { //dcat 2.0写法 $this->response()->error(false); return $this->response()->error($throwable->getMessage())->refresh(); } } public function form() { $this->select("year", "年份")->options(function (){ $list = AdmissionNewStudents::query()->distinct("annual_session")->get("annual_session")->toArray(); if(empty($list)) return []; $list = array_column($list, "annual_session"); $result = []; foreach($list as $item){ $result[$item] = $item; } return $result; })->required(); } }