-1

I am trying to delete a record but when I press delete button it takes me to a white screen. index.blade.php

<form>
   @csrf
   @method('DELETE')
   <button type="submit" formaction="{{ route('user.destroy',$user->id) }}">Delete</button>
</form>

Controller destroy function

public function destroy(User $user)
    {
        User::findOrfail($user->id)->delete();
        return redirect()->route('user.index')->with('success','Record Deleted Successfully!!!');
    }

Route

Route::resource('/onemany/user',UserController::class);

Route List for the project I am trying to delete the record. Tried using anchor tag also but getting same result with it.

  • There's no `action` attribute on the form element, no `name` attribute on the button. One of these is needed. – miken32 Jul 07 '23 at 01:21

1 Answers1

0

Most probably, the problem will occur at the route name and it wont enter the controller method at all.

You could do php artisan route:list and find out the correct route name.

Edit:

                           <form action="{{ route('user.destroy',$user->id) }}" method="Post">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger">Delete</button>
                        </form>
Kevin
  • 1,152
  • 5
  • 13