我可以使用以下命令创建模型和资源 Controller (绑定(bind)到模型)
php artisan make:controller TodoController --resource --model=Todo
我还想使用上述命令创建迁移,可以吗?
最佳答案
从模型开始就可以做到
php artisan make:model Todo -mcr
如果你运行php artisan make:model --help
你可以看到所有可用的选项
-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
更新
正如 @arun 在较新版本的 laravel > 5.6 中的评论中提到的,可以运行以下命令:
php artisan make:model Todo -a
-a, --all Generate a migration, factory, and resource controller for the model
关于Laravel - 在单个 artisan 命令中创建模型、 Controller 和迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187735/