From the course: Building RESTful APIs in Laravel

Unlock the full course today

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

Displaying a specific petition

Displaying a specific petition

From the course: Building RESTful APIs in Laravel

Start my 1-month free trial

Displaying a specific petition

- [Instructor] Earlier, when we were setting up our projects infrastructure, we used the dash dash model flag when creating our controller. What we did was enabled Lavarel model route binding which is just a convenient way to inject the model instance into our routes. If we didn't use the dash dash model we would have an ID as the show method parameter. But since we specified the resource model when we created a controller we now have a petition which gives us an access to the entire model, our show method, will return a petition resource, based on the specific petition it works very similarly to the index method except we're returning a single petition resource. So let's return a new petition resource and pass in the petition. Again, to stop our ID from complaining let's also change the doc block. Let's go to the browser and fetch details of petition ID number five, before we do that. Again, let's remember to…

Contents