Create a Controller
After running the artisan command to create the module, it has only a single route that is implemented as a closure. A better way is to use a controller to manage all the HTTP methods that we might see in an API.
To create a controller, go to the top level of the API and make the artisan command
The argument --resource tells artisan to create all the route endpoints for the standard set of Http types (GET, POST, PUT, DELETE). Without the argument artisan will create an empty controller for you to fill in your own details.
Now let's change the route to use the controller. Edit the file Widgets/Routes/api.php
and replace the closure from previous test with 'WidgetController@index'
.
The route will then be simply