修改数据后提交 报错 Creating default object from empty value
public function update(Request $request, $id) { //查询数据 $student = Student::find($id); //判断请求 if($request->isMethod('POST')) { $data = $request->input('Student'); $student->name = $data['name']; $student->age = $data['age']; $student->sex = $data['sex']; if($student->save()){ return redirect('student/index')->with('success','修改成功-'.$id); } } return view('student.update',[ 'student'=>$student ]); }