In the previous posts I have covered two Laravel 5.4 features called "Laravel 5.4: Fluent Routing" and "Laravel 5.4: New middlewares – TrimStrings and ConvertEmptyStringsToNull. In this post I would like to write about a new
--model flag, by using it you can create resourceful controllers with model boilerplate.
When generating a controller using artisan commands, we used to issue this command
php artisan make:controller. Now from the 5.4 release, you can pass --model flag. For example, to generate a resourceful controller called
postController issue below command, which will generate a resourceful controller that includes a boilerplate to inject the post model in the controller's action.
php artisan make:controller PostController --model="Post"