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.
Displaying a specific petition
From the course: Building RESTful APIs in Laravel
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
-
-
-
-
-
Using API resources to display all petitions6m 5s
-
(Locked)
Saving a new petition2m 24s
-
(Locked)
Displaying a specific petition2m 52s
-
(Locked)
Updating an existing petition2m 17s
-
(Locked)
Deleting a petition4m 27s
-
(Locked)
Challenge: Building the author resource1m 8s
-
(Locked)
Solution: Building the author resource2m 25s
-
-
-