如何在路由器中调用同一控制器的两个方法


How to call two methods of same controller in router

我有两个方法要调用到视图中(同一个控制器)。我该怎么做。例如,这是一条通往视图的路线

 Route::get('url', 'ExampleController@foo');
 Route::get('url', 'ExampleController@bar');

我怎样才能把这两者合并起来。

        You need to code in controller methods i.e

class ExampleController extends CI_Controller {
    public $data;
    public function foo(){
        //inside foo get the view of bar in variable i.e.
        $this->data['bar_view'] = $this->load->view('bar_view',$this->data,true);
        $this->load->view('foo_view',$this->data);
    }
    public function bar(){
        //inside foo get the view of bar in variable i.e.
        $this->data['foo_view'] = $this->load->view('foo_view',$this->data,true);
        $this->load->view('bar_view',$this->data);
    }
}

    // inside view display as the order you want