Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akhileshdarjee/6cf05c9dce148d519fe81cc211df71bb to your computer and use it in GitHub Desktop.
Save akhileshdarjee/6cf05c9dce148d519fe81cc211df71bb to your computer and use it in GitHub Desktop.
Clean and correct way to call a request internally in Laravel 5
// GET request
$request = Request::create(config('app.url') . '/your-url-here', 'GET');
$response = Route::dispatch($request);
return $response;
// POST request
$params = array(
'product_code' => 'GYU16R',
'qty' => '1',
'price' => 660,
);
$request = Request::create(config('app.url') . '/your-url-here', 'POST', $params);
$response = app()->handle($request);
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment