我可以使用以下命令创建一个模型和资源控制器(绑定到模型)
php artisan make:controller TodoController --resource --model=Todo
I want to also create a migration with the above command, is it possible?
我可以使用以下命令创建一个模型和资源控制器(绑定到模型)
php artisan make:controller TodoController --resource --model=Todo
I want to also create a migration with the above command, is it possible?
如果你从模型开始就可以做到
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
Update
As mentioned in the comments by @arun in newer versions of laravel > 5.6 it is possible to run following command:
php artisan make:model Todo -a
-a, --all Generate a migration, factory, and resource controller for the model