Laravel: Load method in another controller without changing the url

前端 未结 4 1458
清歌不尽
清歌不尽 2020-12-07 21:20

I have this route: Route::controller(\'/\', \'PearsController\'); Is it possible in Laravel to get the PearsController to load a method from another controller

4条回答
  •  生来不讨喜
    2020-12-07 21:47

    ( by neto in Call a controller in Laravel 4 )

    Use IoC...

    App::make($controller)->{$action}();
    

    Eg:

    App::make('HomeController')->getIndex();
    

    and you may also give params

    App::make('HomeController')->getIndex($params);
    

提交回复
热议问题