app/Http/Controllers/ClassesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $data=Classes::find($id);
        $data->class_name=request('class_name');
        $data->number_of_students=request('number_of_students');
        $data->save();
      $request->validate([
            'class_name' => 'required',
            'number_of_students' => 'required',
        ]);
      $data->update($request->all());
        return redirect()->route('class.index')
                        ->with('success','User updated successfully');
    }
public function update ( Request $ request , $ id ) { $ data = Classes :: find ( $ id ) ; $ data -> class_name = request ( 'class_name' ) ; $ data -> number_of_students = request ( 'number_of_students' ) ; $ data -> save ( ) ; $ request -> validate ( [ 'class_name' => 'required' , 'number_of_students' => 'required' , ] ) ; $ data -> update ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'class.index' ) -> with ( 'success' , 'User updated successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .