I would do this in JS as so few users have it disabled and the site will still work albeit without the confirmation (plus it would annoy me having to wait for another page load)
That said to do this just do a GET to your "confirm delete" page and pass the ID. The form on the "confirm delete" page would be as above
You can create a middleware asking the user to confirm the action before proceeding to the next request.
We have two methods in our controllers for the delete process, @delete and @destroy.
@delete simply returns a view with a confirmation page and extra warnings if there are relationships that will also be deleted/affected. The view also contains a form submit button saying "Yes, I'm sure" which will POSTs data to the @destroy method.
@destroy deletes the record(s) and returns the user to a page with a flash message saying "Record has been deleted".
This does not require JavaScript and it allows us to customize each delete confirmation page. You could also use a generic confirmation page for all deletes if you'd prefer that.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community