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

后端 未结 14 838
一整个雨季
一整个雨季 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:29

    You can make model + migration + controller, all in one line, using this command:

    php artisan make:model --migration --controller test
    

    Short version: php artisan make:model -mc test

    Output :-

    Model created successfully.

    Created Migration:2018_03_10_002331_create_tests_table

    Controller created successfully.


    If you need to perform all CRUD operations in the controller then use this command:

    php artisan make:model --migration --controller test --resource  
    

    Short version: php artisan make:model -mc test --resource

    0 讨论(0)
  • 2020-12-22 15:30

    Just Try this command on your terminal

    php artisan make:model Todo -mcr
    

    Below the output and your Model, Controller with Resource and Migration file will create...

    Model created successfully.
    Created Migration: 2019_12_25_105305_create_todos_table
    Controller created successfully.
    
    0 讨论(0)
  • 2020-12-22 15:31

    To make all 3: Model, Controller & Migration Schema of table

    write in your console: php artisan make:model NameOfYourModel -mcr

    0 讨论(0)
  • 2020-12-22 15:34

    You can do it with the following command:

    php artisan make:model post -mcr
    

    Brief :

    -m, to create migration

    -c to create controller

    -r to specify the controller has resource

    0 讨论(0)
  • 2020-12-22 15:36

    You can use -m -c -r to make migration, model and controller.

    php artisan make:model Post -m -c -r
    
    0 讨论(0)
  • 2020-12-22 15:38
    php artisan make:model PurchaseRequest -crm
    

    The Result is

    Model created successfully.
    Created Migration: 2018_11_11_011541_create_purchase_requests_table
    Controller created successfully.
    

    Just use -crm instead of -mcr

    0 讨论(0)
提交回复
热议问题