如何在不改变当前路线的情况下发出内部请求。
我的路线:
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"
}
}
调用内部请求时,当前路径会发生变化,我不想要这种效果。我需要做什么?