dimanche 2 juin 2019

How to get property from Request object Laravel?

I have POST data:

[{"id":1,"amount":0,"debit":10,"credit":0,"invoice":{"AC_code":"10","AC_name":"Qeyri-maddi aktivlər","AC_id":2}},
{"id":2,"amount":0,"debit":0,"credit":10,"invoice":{"AC_code":"18","AC_name":"Sair uzunmüddətli maliyyə aktivləri","AC_id":33}}]

I try to iterate incoming array like this:

public function update(Request $request, $id)
{
   foreach($request as $k => $value) {
     echo $value['amount']; // $value->amount
   }

}

But I get error message:

{"errors":"Cannot use object of type Symfony\\Component\\HttpFoundation\\ParameterBag as array"}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire