To call a Laravel 5.*Â Request internally and complete the request life cycle, below are the steps to follow for various methods:
-
GET
$request = Request::create(url, 'GET'); $response = Route::dispatch($request); return $response;
-
POST (with parameters)
$params = array( 'product_code' => 'GYU16R', 'qty' => '1', 'price' => 660, ); $request = Request::create(url, 'POST', $params); $response = app()->handle($request); return $response;
Note:
Always use full absolute path as url while creating request.
Eg: Use http://localhost/edit-user instead of /edit-user