1

How I can make a internal request without change the current route.

My routes:

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

My controller:

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"
    }

}

When the internal request is called, the current route is changed and I don't want this effect. What I need make?

Alex Oliveira
  • 133
  • 1
  • 9

0 Answers0