2

the update form route.. here ..

id) }}" method="POST" enctype='multipart/form-data' > @csrf

web route is here ..

Route::post('admin/updatestudent/{id}', 'StudentController@update_student')->name('admin.update_student');

the student controller. is here

    public function update_student(Request $request,$id){
    $request->validate([
        'name' => 'required |max:150',
        'description' => 'required',
        'image' => 'nullable|image',
        'roll' => 'required',
        'email' => 'required',
        'fname' => 'required',
        'mname' => 'required',
    ]);
    $upstudent=Student::find($id);
    $upstudent->name = $request->name;
    $upstudent->roll = $request->roll;
    $upstudent->fname = $request->fname;
    $upstudent->mname = $request->mname;
    $upstudent->distric = $request->distric;
    $upstudent->dept = $request->dept;
    $upstudent->status = $request->status;
    $upstudent->email = $request->email;
    $upstudent->description = $request->description;
    if (($request->image) > 0) {
        //insert image
        $image = $request->file('image');
        $img = time() . '.' . $image->getClientOriginalExtension();
        $location = public_path('images/student/' . $img);
        Image::make($image)->save($location);
        $upstudent->image = $img;
    }
    $upstudent->save();
    session()->flash('success', 'Student Update  Successfully !!');
    return redirect()->route('admin.update_student');

}
Mahfujur Rahman
  • 157
  • 2
  • 10

1 Answers1

0

You missed a parameter as it stated, I think it should be these:

return redirect()->route('admin.update_student', $id);
tempra
  • 2,455
  • 1
  • 12
  • 27