Reputation: 1274
I use Laravel with an API and make requests using Request::create(...) with parameters. When I use Request::instance() in my API code, I receive the original request, and not the request that I just created with the data I want to use.
Does anyone know what to do?
EDIT:
I make the call with
$request = Request::create('/api/v1/'.$src, strtoupper($params['method']), $params);
$content = Route::dispatch($request)->getContent();
$params is an associative array with the URL get parameters.
Inside the API controller I use:
$request = \Request::instance();
$q = (array) $request->query; // GET
That $q array is empty because it still uses the original request is used. I see this because when I var_dump $request->server->get("REQUEST_URI"), the original route is displayed.
Upvotes: 0
Views: 2342
Reputation: 87749
This is probably a bug on Laravel. I just created a unit test and opened a pull request for the Core Team to check on it: https://github.com/laravel/framework/pull/5886
Upvotes: 2