如何在Laravel 5中获取当前页面的段?

时间:2015-09-07 12:59:41

标签: php get laravel-5

我有这样的网址/project/1

如何获得参数1

我需要在另一个控制器中为另一个路线变量....

这里是考试:

路线1:

Route::get('project/{id}',array(
            'as'   => 'projectID',
            'uses' => 'FirstController@someMethod'
));

路线2:

Route::post('another/route',array(
            'as'   => 'another',
            'uses' => 'SecondController@anotherMethod'
    ));

我需要从anotherMethod进入project/{id} id param ...我尝试过这样return Request::segment(2);但它只返回此路线中的段:another/route ..

任何解决方案?

2 个答案:

答案 0 :(得分:0)

  

你可以试试这个:

<强>控制器:

public function index(Request $request){
        return $request->segment(2); //set the segment number it depends on you
    }

答案 1 :(得分:0)

startBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            handler.post(runnable);

        }
    });

    stopBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            handler.removeCallbacks(runnable);
        }
    });



}
int prolength=0;

Runnable runnable=new Runnable() {

    @Override
    public void run() {

            prolength = inProgressBar.getProgress() + 1;
            inProgressBar.setProgress(prolength);
            timeTextView.setText(String.valueOf(prolength));

            if (prolength < 100) {
                handler.postDelayed(runnable, 1000);
            }

            else {
                inProgressBar.setProgress(0);
                timeTextView.setText(String.valueOf(0));
               handler.post(runnable);
            }

        }

};