Reputation: 13090
I'm creating a model on the Laravel 5 with this command:
php artisan make:model Settings
As it shows on the video lessons that as soon as model is created, new migration file also must be created. But, in my situtation, migration is not being created. How can I get the migration generated when model is created?
composer.json:
...
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
...
Upvotes: 92
Views: 319442
Reputation: 2935
Create Model and Migration :
php artisan make:model Image -m
Create Model, Migration and Controller with resource :
php artisan make:model Image -mcr
Shortcut to generate a model, migration, factory, seeder, policy, controller, and form requests :
php artisan make:model Image --all
Upvotes: 20
Reputation: 482
Also you can use this command:
php artisan make:model ModelName -m
and if you wanna make controller for your model, you should write this command :
php artisan make:model ModelName -mc
// or
php artisan make:model ModelName -mcr //(r: for resource methods)
Upvotes: 30
Reputation: 6919
Try using this Command
php artisan make:model ModelName -m
OR
php artisan make:model ModelName --migration
It will create model with migration class
Upvotes: 66
Reputation: 11978
2020 update:
You can now do:
php artisan make:model ModelName -a
To create a:
All using one command.
Upvotes: 23
Reputation: 4074
You can use the make:model
flags like;
php artisan make:model Setting -m
Help: php artisan make:model --help
Upvotes: 16
Reputation: 2993
If you would like to generate a database migration when you generate the model, you may use the --migration or -m option
php artisan make:model Settings --migration
php artisan make:model Settings -m
Upvotes: 1
Reputation: 2179
I'm guessing your build of L5 is fairly old, as they disabled creating migrations alongside the model creation.
Try running the ff:
php artisan make:model Settings --migration
Upvotes: 158
Reputation: 5422
It's weird because to skip migration you could use the flag --no-migration
. That means that calling php artisan make:model Foo
should automatically create everything. Does artisan show any errors? Did you check logs? What Laravel version are you using? 5? 5.1?
Upvotes: 1