Laravel can I add two update method on a resource controller [duplicate]












0
















This question already has an answer here:




  • Add new methods to a resource controller in Laravel

    7 answers




I'm new to laravel and I would like to add another Update method from the created resource controller UsersController.
something like this:



  public function update(Request $request, $id)
{
"logic here"
}
public function update2(Request $request, $id)
{
"logic here"
}


but i do not know how to access "update2". is there a way to do this?










share|improve this question















marked as duplicate by Community Nov 22 '18 at 5:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • Add new methods to a resource controller in Laravel

      7 answers




    I'm new to laravel and I would like to add another Update method from the created resource controller UsersController.
    something like this:



      public function update(Request $request, $id)
    {
    "logic here"
    }
    public function update2(Request $request, $id)
    {
    "logic here"
    }


    but i do not know how to access "update2". is there a way to do this?










    share|improve this question















    marked as duplicate by Community Nov 22 '18 at 5:37


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • Add new methods to a resource controller in Laravel

        7 answers




      I'm new to laravel and I would like to add another Update method from the created resource controller UsersController.
      something like this:



        public function update(Request $request, $id)
      {
      "logic here"
      }
      public function update2(Request $request, $id)
      {
      "logic here"
      }


      but i do not know how to access "update2". is there a way to do this?










      share|improve this question

















      This question already has an answer here:




      • Add new methods to a resource controller in Laravel

        7 answers




      I'm new to laravel and I would like to add another Update method from the created resource controller UsersController.
      something like this:



        public function update(Request $request, $id)
      {
      "logic here"
      }
      public function update2(Request $request, $id)
      {
      "logic here"
      }


      but i do not know how to access "update2". is there a way to do this?





      This question already has an answer here:




      • Add new methods to a resource controller in Laravel

        7 answers








      laravel php-7 laravel-5.7 laravel-controller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 5:09







      Vanz

















      asked Nov 21 '18 at 4:51









      VanzVanz

      12112




      12112




      marked as duplicate by Community Nov 22 '18 at 5:37


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Community Nov 22 '18 at 5:37


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          3 Answers
          3






          active

          oldest

          votes


















          0














          You would only need add another route to your routes/web.php file. For example:



          Route::post('/users/{user}/update2', 'UsersController@update2');


          As you've mentioned it being a resource controller, you may have already added something similar to:



          Route::resource('users', 'UsersController');


          This will create the corresponding index, show, store, update, and destroy routes.






          share|improve this answer































            0














            You can simply access update2 like this :



            Route::get('route-name', 'YourCOntroller@update2');





            share|improve this answer































              -1














              Resource route will create URL like user/{id}



              You have to create another route for the update2 in web.php like



              Route::put('user/{id}/update2', 'V1UserController@update2');






              share|improve this answer






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                You would only need add another route to your routes/web.php file. For example:



                Route::post('/users/{user}/update2', 'UsersController@update2');


                As you've mentioned it being a resource controller, you may have already added something similar to:



                Route::resource('users', 'UsersController');


                This will create the corresponding index, show, store, update, and destroy routes.






                share|improve this answer




























                  0














                  You would only need add another route to your routes/web.php file. For example:



                  Route::post('/users/{user}/update2', 'UsersController@update2');


                  As you've mentioned it being a resource controller, you may have already added something similar to:



                  Route::resource('users', 'UsersController');


                  This will create the corresponding index, show, store, update, and destroy routes.






                  share|improve this answer


























                    0












                    0








                    0







                    You would only need add another route to your routes/web.php file. For example:



                    Route::post('/users/{user}/update2', 'UsersController@update2');


                    As you've mentioned it being a resource controller, you may have already added something similar to:



                    Route::resource('users', 'UsersController');


                    This will create the corresponding index, show, store, update, and destroy routes.






                    share|improve this answer













                    You would only need add another route to your routes/web.php file. For example:



                    Route::post('/users/{user}/update2', 'UsersController@update2');


                    As you've mentioned it being a resource controller, you may have already added something similar to:



                    Route::resource('users', 'UsersController');


                    This will create the corresponding index, show, store, update, and destroy routes.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 21 '18 at 5:47









                    DigitalDrifterDigitalDrifter

                    8,3382624




                    8,3382624

























                        0














                        You can simply access update2 like this :



                        Route::get('route-name', 'YourCOntroller@update2');





                        share|improve this answer




























                          0














                          You can simply access update2 like this :



                          Route::get('route-name', 'YourCOntroller@update2');





                          share|improve this answer


























                            0












                            0








                            0







                            You can simply access update2 like this :



                            Route::get('route-name', 'YourCOntroller@update2');





                            share|improve this answer













                            You can simply access update2 like this :



                            Route::get('route-name', 'YourCOntroller@update2');






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 21 '18 at 5:46









                            dvl333dvl333

                            495




                            495























                                -1














                                Resource route will create URL like user/{id}



                                You have to create another route for the update2 in web.php like



                                Route::put('user/{id}/update2', 'V1UserController@update2');






                                share|improve this answer




























                                  -1














                                  Resource route will create URL like user/{id}



                                  You have to create another route for the update2 in web.php like



                                  Route::put('user/{id}/update2', 'V1UserController@update2');






                                  share|improve this answer


























                                    -1












                                    -1








                                    -1







                                    Resource route will create URL like user/{id}



                                    You have to create another route for the update2 in web.php like



                                    Route::put('user/{id}/update2', 'V1UserController@update2');






                                    share|improve this answer













                                    Resource route will create URL like user/{id}



                                    You have to create another route for the update2 in web.php like



                                    Route::put('user/{id}/update2', 'V1UserController@update2');







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 21 '18 at 5:47









                                    Hardik PrajapatiHardik Prajapati

                                    502




                                    502















                                        Popular posts from this blog

                                        MongoDB - Not Authorized To Execute Command

                                        How to fix TextFormField cause rebuild widget in Flutter

                                        Npm cannot find a required file even through it is in the searched directory