You can make easily model,controller or migration with small amount of command (Terminal) in Laravel

Create Model Command: 

php artisan make:model Post


Create Controller Command: 

php artisan make:controller PostController


Create Migration Command: 

php artisan make:migration create_posts_table

All of the above commands are a single command to create a model, controller, or migration.


You will use below command to create a controller and migration for your model;

php artisan make:model Post -c -m

Here you can get your controller and migration associate for the model.


You can see a list of options using the help option for each model, controller, and migrations. 

php artisan make:model --help


You can generate migration, controller and resource for the model via below command :

php artisan make:model Post --mcr


You can generate all of the required files associate with model then you can run below command :

php artisan make:model Post -a

-a, --a generate a migration, factory, and resource controller for the model


The most popular/basic options for each of the aforementioned commands are displayed separately in the details below.

Model

  • -a or — all generate a migration, seeder, factory, and resource controller with the associate model
  • -c or — controller Create a new controller with the associate model
  • -m or — migration Create a new migration file with the associate model


Controller:

  • -m or — model[=MODEL] Generate a resource controller for the given model.
  • -r or — resource Generate a resource controller class.


Hope this article help you to create about laravel model, controller, migration artisan command.





Share