Laravel 5.4 create model, controller and migration in single artisan command

后端 未结 14 978
一整个雨季
一整个雨季 2020-12-22 14:35

I can create a model and resource controller (binded to model) with the following command

php artisan make:controller TodoController --resource --model=Todo
         


        
14条回答
  •  抹茶落季
    2020-12-22 15:24

    You can do it if you start from the model

    php artisan make:model Todo -mcr
    

    if you run php artisan make:model --help you can see all the available 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

    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

提交回复
热议问题