NOTE. As vcardillo pointed out below, route filters are not called using these methods.
I am doing the same thing now, and Jason replied that I was going in a different direction. Looking at the Symfony \ Component \ HttpFoundation \ Request documentation, I figured out how to POST, as well as everything else, that I will need to do. Assuming you are using a form, here is some code that might help you:
Get
$request = Request::create('/api/users/1', 'GET'); $response = Route::dispatch($request);
POST:
$request = Request::create('/api/users/1', 'POST', Input::get()); $response = Route::dispatch($request);
Cookie post
$request = Request::create('/api/users/1', 'POST', Input::get(), Cookie::get('name')); $response = Route::dispatch($request);
POST with files
$request = Request::create('/api/users/1', 'POST', Input::get(), null, Input::file('file')); $response = Route::dispatch($request);
Hope this helps someone else. If you are not using a form or using but not using the Laravel Input / Cookie facade, replace the Input / Cookie facades with your content.
Domenic Fiore Mar 18 '14 at 23:36 2014-03-18 23:36
source share