Home > Tips & Tricks > Create Laravel Model, Migration, Controller, and Resource in One Command

Create Laravel Model, Migration, Controller, and Resource in One Command

Yes, you can create a model, migration, controller, and resource (views) with one command in the laravel. You just have to add an additional flag while creating a new model with the PHP artisan command. So let’s see how we can do this.

We all know this PHP artisan command for creating a model.

php artisan make:model user

Now we will add an additional flag to tell the artisan command to also create a migration, controller, and resource along with the model. See the command below.

php artisan make:model user -mcr

The above command will generate the files for migration, controller, and resource (view), and of course model files. This is short abbreviation command for creating all together in one command.

-m => for create the migration
-c => for create the controller
-r => for create the resource

Hope this trick will help you to create a model, migration, resource, and controller with one laravel command. So use this trick to save your time. You can read more about artisan command here.

Being Tricky 😉

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment