Skip to content

Laravel 5.4 – Resourceful Controllers With Model Boilerplate

Last updated on February 17, 2018

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"
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments