Created
April 22, 2019 14:20
-
-
Save akhileshdarjee/6cf05c9dce148d519fe81cc211df71bb to your computer and use it in GitHub Desktop.
Clean and correct way to call a request internally in Laravel 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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