*My code snippets plugin seems to be crapping out. Apologies for the formatting. Will try to fix soon.
When creating CRUD pages we’ll eventually need to create delete links for records. In Laravel these links need to fire a post request to an endpoint with two fields:
- _method which is DELETE
- _token which has the csrf token
Here’s bit of jQuery code I put together for a recent project to help with this. Once in place, you’ll only need to create a delete link and give it the data-delete attribute with the value of the URL endpoint. Here’s how to use it: