This video demonstrates the changes in using Artisan to make controllers that better reflect the needs of an API resource endpoint.
- [Instructor] Laravel 5.6 didn't just add new features,…as you might have expected.…Many existing features in Laravel…also got improved with the update.…We'll look at those updates in this chapter.…First off is generating controllers.…A standard Laravel pattern is to use…the artisan make command to make controllers.…Let's try it out now.…We'll open up our Terminal editor and we'll run the command,…php artisan make:controller…AnswersController --resource…- -model=Answer.…
Let's look at our controller that we created.…If we go to our text editor and open up…App, Http, Controllers, AnswersController.php…You'll see that we generated a…fairly standard resource controller.…It has an index, a create, a store,…a show, edit, update, and destroy methods.…However, if we're building a controller…for an API, one of the issues we have…is we have these extra functions for…create and edit that we don't actually need.…
In a web interface it might make sense,…but here in an API we don't need to display…the forms for creating and editing a record.…
Share this video
Embed this video
Video: API controller generation