Laravel create model migration and controller in a single command

Laravel create model, migration and controller in a single command

Hello guys, sometimes while working on the large application, we need to create some very small modules like simple CRUD. So here in this article i will let you know laravel create model migration and controller in a single command.

We will run a single artisan command to create model. migration and controller. We can also create resource controller by giving parameter.

We can these model, migration and controller from three command but for time saving laravel provides feature to create thses three thing by one single command.

So for desired result open your terminal and run the following command.

php artisan make:model --migration --controller Product --resource  

Here, we have create product model, migration and product controller with all the resources methods.

We can also write this command in the short form like below. 

php artisan make:model -mc Product --resource

You can also write this command in a more short way like below.

php artisan make:model Product -mcr

Note: Here, m represents migration, c represents controller and r represents as  resource.

After running the above command you will get the output like

Model created successfully

Created migration (migration file name with current date and migration name )

Controller created successfully.

You can also read the article to create to add a column in the existing table through migration by clicking on the link below.

How to add column in laravel existing table through migration