Support the ongoing development of Laravel.io →
posted 9 years ago
Architecture
Last updated 2 years ago.
0

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

0

You can create a middleware asking the user to confirm the action before proceeding to the next request.

0

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.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

0Neji 0neji Joined 15 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.