From the course: Building RESTful APIs in Laravel

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

PATCH (update) a petition

PATCH (update) a petition

From the course: Building RESTful APIs in Laravel

Start my 1-month free trial

PATCH (update) a petition

- [Instructor] Let's test the update method of the petitions controller. Create a new request, give it a name, update the petition, and save it in the ePetitions collection. By the way, the way I named the request is just a personal preference. You can choose your own naming convention. When updating a resource, you can choose between the PUT and PATCH HTTP verbs. We spoke about a difference between these two earlier in the course. But even if you are not sure which one to use, you can look at the route list. You can see that Laravel will accept either of them. I'm going to choose PATCH. The request URL will be the same one as the one we used in saving a new petition. We will use the petition variable and add the petition ID at the end. Let's update the petition with ID 20. Updating a resource is similar to creating a new one in Postman. Since we have to create the body of the request ourself. Switch to the body tab,…

Contents