rental.get
method in the rental controller to return the list of rentals managed by the rental service. There were other methods in the rental service, such as create()
, get(id)
, and remove(id)
, that we did not use. So, let's update our application to provide routes that call use these methods.rental
controller become a resource controller.Controller
to ResourceController
, and define the name property on the controller as rental
.ResourceController
instead of the Controller
. This gives our controller the ability to selectively extend the actions defined in the ResourceController
class. The get()
method is one of the methods defined on the ResourceController
, so we do not have do anything.ResourceController
extends the Controller
, which is why theResourceController
is still considered a Controller.name
property. This is a required property because the router uses this name when it is auto-generating the routes for the corresponding resource, as shown in the table below with their corresponding method on the ResourceController
.create()
POST
/
getAll()
GET
/
getOne()
GET
/:nameId
update()
PUT
/:nameId
delete()
DELETE
/:nameId
create
getOne
getAll
delete
ResourceController
methods that are not overridden return a 404 Not Found
HTTP response to the client.getOne()
and getAll()
. The getOne() method is define an action that returns a single resource and the getAll() method is define an action that returns resources that match the query. If there is no query, then we should return all the resources. Below is the implementation of getOne()
and getAll()
.