Laravel PUT request parameter

When the route is:

  Route::post('/abcd',...); 

Then in controller I get the parameter like this:

   $r->get('param')   // with Request $r

But while the route is of a PUT request type:

   Route::put('/abcd,...);

That code doesn't work. It doesn't get the value of parameter.

Answers


Try setting x-www-form-urlencoded for body in the postman.


Set method to POST and add _method field with PUT value


Route:

$api->put('photos', 'App\Api\V1\Controllers\PhotoController@updatePhoto');

Controller code:

public function updatePhoto(Request $request)
{
    $paramValue = $request->get('param_name');
}

Working fine for me.


<input type="hidden" name="_method" value="PUT">

Just added an extra field in form. works perfect!


If submitting an API request and you don't want your developers to send a POST request with _method=PUT request variable, see solution here: https://github.com/laravel/framework/issues/13457#issuecomment-341973180


Need Your Help

Xcode 8 Issue : Frame for "Navigation Bar" will be different at run time

ios xcode xcode8

When we Embed your view controller in Navigation Controller. Then facing issue with navigation bar.

Show only two digit after decimal

java android number-formatting

How to get the double value that is only two digit after decimal point.