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
# log in to Dockerdocker exec -it elentra-developer bash# navigate to the API rootcd /var/www/vhosts/elentra-1x-me/www-root/core/library/vendor/elentrapackages/elentra-1x-api# create a widget controllerphp artisan make:module:controller widgets WidgetController --resource
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
The route will then be simply