Laravel create model, controller and migration in single artisan command

For Laravel 8 and newer:

php artisan make:model Todo -mcr

-m, –migration Create a new migration file for the model.
-c, –controller Create a new controller for the model.
-r, –resource Indicates if the generated controller should be a resource controller

and for Laravel 5.7, 6 and 7 and older:

php artisan make:model Todo -a

-a, –all Generate a migration, factory, and resource controller for the model

or you can make model + migration + controller, all in one line, using this command:

php artisan make:model --migration --controller Todo


Model created successfully.

Created Migration: 2020_04_11_202633_create_todos_table

Controller created successfully.

and if you need to perform all CRUD operations in the controller then use this command:

php artisan make:model -mc Todo --resource

Leave a Comment