0
Angularjs file
$http({
method: 'POST',
url: API_URL + "produto/update" + "/" + produtoSelecionado,
data: $.param(obj),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function (response) {
console.log(response);
alert(response);
location.reload();
}).error(function (response) {
console.log(response);
alert('An error has occured. Please check the log for details.');
});
location.reload();
php controller:
public function decreaseQuantity(Request $request, $id)
{
DB::table('product') ->where('id', $id) -> decrement('quantity',$request->input('quantity'));
}
It always gives me error that the value is null as it is in the image
I’ve already checked the value of the variable obj
and it has the value I want but for some reason does not pass to the controller. And even if I put a fixed value it also does not pass.. Any suggestions?
Have you tried using $request->json()->get('Quantity') ??
– SylvioT
@Sylviot already but without success. The strange thing is that I have another function that takes exactly the same variable only instead of doing decrement makes increment and works well, only this is not
– Hugo