内部请求不更改当前路由

时间:2016-07-08 13:22:22

标签: laravel singleton http-request

如何在不改变当前路线的情况下发出内部请求。

我的路线:

Route::get('/my/action1', ['as' => 'action1', 'uses' => 'MyController@action1']);
Route::get('/my/action2', ['as' => 'action2', 'uses' => 'MyController@action2']);

我的控制器:

namespace App\Http\Controllers;

use Route;
use Request;
class MyController extends Controller
{

    public function action1()
    {
        return 'action1';
    }

    public function action2()
    {
        $request = Request::create('/my/action1', 'GET');
        $response = app()->handle($request);

        dump(Route::getCurrentRoute()->getName()); // I need return "action2"

        return $response; // I need return "action1"
    }

}

调用内部请求时,当前路径会发生变化,我不想要这种效果。我需要做什么?

0 个答案:

没有答案