Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alex-oliveira/0d8e854e6e4d417fe337c768b28e8997 to your computer and use it in GitHub Desktop.
Save alex-oliveira/0d8e854e6e4d417fe337c768b28e8997 to your computer and use it in GitHub Desktop.
Internal Resquest
$input = Request::input();
$request = clone app('request');
$route = clone app('Illuminate\Routing\Route');
$router = clone app('router');
$internal = Request::create(route('action1'), 'GET', ['alex' => 'oliveira']);
Request::replace($internal->input());
$dispatch = Route::dispatch($internal);
$response = method_exists($dispatch, 'getOriginalContent') ? $dispatch->getOriginalContent() : $dispatch->getContent();
app()->instance('router', $router);
app()->instance('Illuminate\Routing\Route', $route);
app()->instance('request', $request);
Request::replace($input);
dump(Route::getCurrentRoute()->getName());
dump(app('router')->getCurrentRoute()->getName());
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment