mercredi 9 septembre 2020

Laravel delete by Id

Hey Im trying to delete a record in laravel but I get this error: Undefined variable: row (View: C:\xampp\htdocs\Laravel\laravel\resources\views\admin\addEmployee.blade.php) at this row : <form action="/deleteEmployee/" method="POST">

What might be possibly going wrong?

 <form action="/deleteEmployee/" method="POST">
              
              
                <button type="submit" class="btn btn-danger">DELETE</button>
              </form>

Controller

 public function deleteEmployee( $id)
   {
      $users = User::findOrFail($id);
      $users -> delete();

      return redirect('addEmployee')->with('status','Employee record is deleted');
   }

Route

Route::delete('/deleteEmployee/{id}','Admin\DashboardController@deleteEmployee');


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire