0

When you want to delete an item from the db, I know that you can use /resource/{id} and use the contrller@destroy action.

What is the advantage of passing a parameter in the URL as oppose to send a DELETE request and pass the parameter $id via an Input?

1 Answer 1

3

You can certainly do both, but the first method (using the dedicated /resource/{id} URL) is following the RESTFUL design pattern. Here is a very good video on that.

To highlight some important points:

  • We avoid verbs in URLs, unless they're used for very specific actions. We should try to use nouns instead if it's possible, so a url like /resource/deleteis not advisable.
  • When someone used to the REST way of communicating with an API uses 'DELETE' on the /resource url, he/she expects to delete ALL resources. If he/she uses it on /resource/{id}, then only that specific item should be removed.

Hope this made sense =)

1
  • Ahh that makes more sense! Thanks
    – Kousha
    Commented Apr 5, 2014 at 9:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.