Home / Blog /

Create migration and controller for make:model using flags

3 years ago

Create migration and controller for make:model using flags

One of the most frequently used commands while building a project is the php artisan make:model command. But did you know you can pass additional flags to quickly generate (RESTful) controllers and a migration file?

👀 417 views

There are a couple of flags that can be used to create files like migration and controllers for your models. Additionally, a flag can be passed to make that controller RESTful. The following command is probably familiar to you:

php artisan make:model Subscription

The following flags can be used:
  • -m to create a migration file (in this case 2021_01_01_000000_create_subscriptions_table)
  • -c to create a controller file (in this case App\Http\Controllers\SubscriptionController.php)
  • -r to make that controller RESTful

If you combined these flags, use them in one statement, like below:

php artisan make:model Subscription -mcr