ITellMyselfSecrets's avatar

How can I create a migration and a model at once

Hi, the questions is pretty clear. How can I create a model and a migration at once. They always have the same name and I'm tired of doing that at once. Does anyone have a script for me for that?

0 likes
1 reply
bobbybouwmann's avatar
Level 88

Hi,

You create a migration and a model at once by running

php artisan make:model -m Product

// Will output
Model created successfully.
Created Migration: 2017_11_25_083612_create_products_table

You can also create your controller at once, for more options you need to run:

php artisan make:model -h

// Output
Usage:
  make:model [options] [--] <name>

Arguments:
  name                  The name of the class

Options:
  -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
2 likes

Please or to participate in this conversation.