Afraz Ahmad
Afraz Ahmad

Reputation: 5386

laravel 5.3 put, patch and delete routes. What are they and how to use them?

I have knowledge of get and post routes but I want to learn how to use these routes (put, patch and delete) and what are their pros and cons. Till now I have used get and post to get, update or delete the record. I think it is not correct way to do it. Definitely they also have a purpose. If anyone can explain then please do it. Thanks.

Upvotes: 1

Views: 909

Answers (1)

arku
arku

Reputation: 1707

The best way to explain is show how REST API works. Just imagine a book.

  • GET /book - get one books
  • POST /book - store a book
  • DELETE /book - delete a book
  • PATCH /book - modify book

  • GET /books - get list of books

  • POST /books - post many books
  • DELETE /books - delete all books

Different method for different actions and no needs of naming it like: '/getBook', '/deleteBook' and etc

Upvotes: 2

Related Questions