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










80















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



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


I want to also create a migration with the above command, is it possible?










share|improve this question
























  • I think in this case the flag --resource is not needed. --model is enough.

    – Stratboy
    Oct 7 '18 at 16:21















80















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



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


I want to also create a migration with the above command, is it possible?










share|improve this question
























  • I think in this case the flag --resource is not needed. --model is enough.

    – Stratboy
    Oct 7 '18 at 16:21













80












80








80


32






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



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


I want to also create a migration with the above command, is it possible?










share|improve this question
















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



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


I want to also create a migration with the above command, is it possible?







laravel laravel-5.4 artisan






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 27 '17 at 12:47









Christophvh

4,58033247




4,58033247










asked Apr 3 '17 at 14:48









arunarun

1,6661819




1,6661819












  • I think in this case the flag --resource is not needed. --model is enough.

    – Stratboy
    Oct 7 '18 at 16:21

















  • I think in this case the flag --resource is not needed. --model is enough.

    – Stratboy
    Oct 7 '18 at 16:21
















I think in this case the flag --resource is not needed. --model is enough.

– Stratboy
Oct 7 '18 at 16:21





I think in this case the flag --resource is not needed. --model is enough.

– Stratboy
Oct 7 '18 at 16:21












9 Answers
9






active

oldest

votes


















197














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







share|improve this answer




















  • 12





    Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

    – arun
    Apr 11 '18 at 12:43


















6














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.






share|improve this answer


















  • 1





    please use php artisan make:model --migration --controller --resource Test .

    – Affan
    Apr 30 '18 at 5:55












  • bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

    – Affan
    Apr 30 '18 at 8:24











  • I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

    – Udhav Sarvaiya
    Apr 30 '18 at 9:14


















5














You can do it with the following command:



php artisan make:model post -mc





share|improve this answer

























  • just use this command

    – sunil
    Oct 14 '17 at 12:40











  • Op had resource in his question so your answer is incomplete.

    – Landon Call
    Apr 12 '18 at 3:05


















2














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






share|improve this answer
































    1














    To make mode, controllers with resources, You can type CMD as follows :



     php artisan make:model Todo -mcr


    or you can check by typing



    php artisan help make:model


    where you can get all the ideas






    share|improve this answer






























      1














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



      php artisan make:model Post -m -c -r





      share|improve this answer
































        0














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



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






        share|improve this answer






























          0














          Laravel 5.4 You can use



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


          This will create
          1) Model
          2) controller with default resource function
          3) Migration file



          And Got Answer



          Model created successfully.



          Created Migration: 2018_04_30_055346_create_tests_table



          Controller created successfully.






          share|improve this answer






























            0














            We can use php artisan make:model Todo -a to create model, migration, resource controller and factory






            share|improve this answer






















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43187735%2flaravel-5-4-create-model-controller-and-migration-in-single-artisan-command%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              9 Answers
              9






              active

              oldest

              votes








              9 Answers
              9






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              197














              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







              share|improve this answer




















              • 12





                Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

                – arun
                Apr 11 '18 at 12:43















              197














              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







              share|improve this answer




















              • 12





                Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

                – arun
                Apr 11 '18 at 12:43













              197












              197








              197







              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







              share|improve this answer















              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








              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 24 '18 at 13:36

























              answered Apr 3 '17 at 14:52









              ChristophvhChristophvh

              4,58033247




              4,58033247







              • 12





                Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

                – arun
                Apr 11 '18 at 12:43












              • 12





                Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

                – arun
                Apr 11 '18 at 12:43







              12




              12





              Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

              – arun
              Apr 11 '18 at 12:43





              Now we can use php artisan make:model Todo -a to create model, migration, resource controller and factory

              – arun
              Apr 11 '18 at 12:43













              6














              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.






              share|improve this answer


















              • 1





                please use php artisan make:model --migration --controller --resource Test .

                – Affan
                Apr 30 '18 at 5:55












              • bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

                – Affan
                Apr 30 '18 at 8:24











              • I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

                – Udhav Sarvaiya
                Apr 30 '18 at 9:14















              6














              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.






              share|improve this answer


















              • 1





                please use php artisan make:model --migration --controller --resource Test .

                – Affan
                Apr 30 '18 at 5:55












              • bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

                – Affan
                Apr 30 '18 at 8:24











              • I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

                – Udhav Sarvaiya
                Apr 30 '18 at 9:14













              6












              6








              6







              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.






              share|improve this answer













              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.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 9 '18 at 11:00









              Udhav SarvaiyaUdhav Sarvaiya

              1,81261424




              1,81261424







              • 1





                please use php artisan make:model --migration --controller --resource Test .

                – Affan
                Apr 30 '18 at 5:55












              • bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

                – Affan
                Apr 30 '18 at 8:24











              • I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

                – Udhav Sarvaiya
                Apr 30 '18 at 9:14












              • 1





                please use php artisan make:model --migration --controller --resource Test .

                – Affan
                Apr 30 '18 at 5:55












              • bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

                – Affan
                Apr 30 '18 at 8:24











              • I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

                – Udhav Sarvaiya
                Apr 30 '18 at 9:14







              1




              1





              please use php artisan make:model --migration --controller --resource Test .

              – Affan
              Apr 30 '18 at 5:55






              please use php artisan make:model --migration --controller --resource Test .

              – Affan
              Apr 30 '18 at 5:55














              bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

              – Affan
              Apr 30 '18 at 8:24





              bro i create first and then post this . actually i use your given command and add --resource at end and this work please check from you end . I am useing laravel 5.4 . may lower version of laravel not support . @Udhav

              – Affan
              Apr 30 '18 at 8:24













              I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

              – Udhav Sarvaiya
              Apr 30 '18 at 9:14





              I installed fresh Laravel, Your suggestion code is working, thank you @Affan :)

              – Udhav Sarvaiya
              Apr 30 '18 at 9:14











              5














              You can do it with the following command:



              php artisan make:model post -mc





              share|improve this answer

























              • just use this command

                – sunil
                Oct 14 '17 at 12:40











              • Op had resource in his question so your answer is incomplete.

                – Landon Call
                Apr 12 '18 at 3:05















              5














              You can do it with the following command:



              php artisan make:model post -mc





              share|improve this answer

























              • just use this command

                – sunil
                Oct 14 '17 at 12:40











              • Op had resource in his question so your answer is incomplete.

                – Landon Call
                Apr 12 '18 at 3:05













              5












              5








              5







              You can do it with the following command:



              php artisan make:model post -mc





              share|improve this answer















              You can do it with the following command:



              php artisan make:model post -mc






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Oct 14 '17 at 19:37









              jrtapsell

              3,96111237




              3,96111237










              answered Oct 14 '17 at 12:36









              sunilsunil

              5912




              5912












              • just use this command

                – sunil
                Oct 14 '17 at 12:40











              • Op had resource in his question so your answer is incomplete.

                – Landon Call
                Apr 12 '18 at 3:05

















              • just use this command

                – sunil
                Oct 14 '17 at 12:40











              • Op had resource in his question so your answer is incomplete.

                – Landon Call
                Apr 12 '18 at 3:05
















              just use this command

              – sunil
              Oct 14 '17 at 12:40





              just use this command

              – sunil
              Oct 14 '17 at 12:40













              Op had resource in his question so your answer is incomplete.

              – Landon Call
              Apr 12 '18 at 3:05





              Op had resource in his question so your answer is incomplete.

              – Landon Call
              Apr 12 '18 at 3:05











              2














              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






              share|improve this answer





























                2














                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






                share|improve this answer



























                  2












                  2








                  2







                  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






                  share|improve this answer















                  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







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 11 '18 at 1:48









                  Stephen Rauch

                  28.3k153356




                  28.3k153356










                  answered Nov 11 '18 at 1:23









                  G Dhe Einstein gedeeinsteinG Dhe Einstein gedeeinstein

                  261




                  261





















                      1














                      To make mode, controllers with resources, You can type CMD as follows :



                       php artisan make:model Todo -mcr


                      or you can check by typing



                      php artisan help make:model


                      where you can get all the ideas






                      share|improve this answer



























                        1














                        To make mode, controllers with resources, You can type CMD as follows :



                         php artisan make:model Todo -mcr


                        or you can check by typing



                        php artisan help make:model


                        where you can get all the ideas






                        share|improve this answer

























                          1












                          1








                          1







                          To make mode, controllers with resources, You can type CMD as follows :



                           php artisan make:model Todo -mcr


                          or you can check by typing



                          php artisan help make:model


                          where you can get all the ideas






                          share|improve this answer













                          To make mode, controllers with resources, You can type CMD as follows :



                           php artisan make:model Todo -mcr


                          or you can check by typing



                          php artisan help make:model


                          where you can get all the ideas







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered May 16 '18 at 19:20









                          Nirmal KhadkaNirmal Khadka

                          211




                          211





















                              1














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



                              php artisan make:model Post -m -c -r





                              share|improve this answer





























                                1














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



                                php artisan make:model Post -m -c -r





                                share|improve this answer



























                                  1












                                  1








                                  1







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



                                  php artisan make:model Post -m -c -r





                                  share|improve this answer















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



                                  php artisan make:model Post -m -c -r






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Oct 21 '18 at 16:40









                                  raBne

                                  1,71112032




                                  1,71112032










                                  answered May 23 '18 at 18:00









                                  Deepak singh ThakurDeepak singh Thakur

                                  11117




                                  11117





















                                      0














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



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






                                      share|improve this answer



























                                        0














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



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






                                        share|improve this answer

























                                          0












                                          0








                                          0







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



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






                                          share|improve this answer













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



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







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Apr 10 '18 at 5:40









                                          clusterBuddyclusterBuddy

                                          544314




                                          544314





















                                              0














                                              Laravel 5.4 You can use



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


                                              This will create
                                              1) Model
                                              2) controller with default resource function
                                              3) Migration file



                                              And Got Answer



                                              Model created successfully.



                                              Created Migration: 2018_04_30_055346_create_tests_table



                                              Controller created successfully.






                                              share|improve this answer



























                                                0














                                                Laravel 5.4 You can use



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


                                                This will create
                                                1) Model
                                                2) controller with default resource function
                                                3) Migration file



                                                And Got Answer



                                                Model created successfully.



                                                Created Migration: 2018_04_30_055346_create_tests_table



                                                Controller created successfully.






                                                share|improve this answer

























                                                  0












                                                  0








                                                  0







                                                  Laravel 5.4 You can use



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


                                                  This will create
                                                  1) Model
                                                  2) controller with default resource function
                                                  3) Migration file



                                                  And Got Answer



                                                  Model created successfully.



                                                  Created Migration: 2018_04_30_055346_create_tests_table



                                                  Controller created successfully.






                                                  share|improve this answer













                                                  Laravel 5.4 You can use



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


                                                  This will create
                                                  1) Model
                                                  2) controller with default resource function
                                                  3) Migration file



                                                  And Got Answer



                                                  Model created successfully.



                                                  Created Migration: 2018_04_30_055346_create_tests_table



                                                  Controller created successfully.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Apr 30 '18 at 8:28









                                                  AffanAffan

                                                  800313




                                                  800313





















                                                      0














                                                      We can use php artisan make:model Todo -a to create model, migration, resource controller and factory






                                                      share|improve this answer



























                                                        0














                                                        We can use php artisan make:model Todo -a to create model, migration, resource controller and factory






                                                        share|improve this answer

























                                                          0












                                                          0








                                                          0







                                                          We can use php artisan make:model Todo -a to create model, migration, resource controller and factory






                                                          share|improve this answer













                                                          We can use php artisan make:model Todo -a to create model, migration, resource controller and factory







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 22 hours ago









                                                          Prakash PazhanisamyPrakash Pazhanisamy

                                                          8401923




                                                          8401923



























                                                              draft saved

                                                              draft discarded
















































                                                              Thanks for contributing an answer to Stack Overflow!


                                                              • Please be sure to answer the question. Provide details and share your research!

                                                              But avoid


                                                              • Asking for help, clarification, or responding to other answers.

                                                              • Making statements based on opinion; back them up with references or personal experience.

                                                              To learn more, see our tips on writing great answers.




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43187735%2flaravel-5-4-create-model-controller-and-migration-in-single-artisan-command%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                                                              Edmonton

                                                              Crossroads (UK TV series)