jeudi 21 janvier 2021

Storing an array of objects in laravel

I have this request

"products":[
        {
           
            "quantity_accepted":15,
            
        },
        {
            
            "quantity_accepted":17,
           
        },
        {
           
            "quantity_accepted":17
        }
    ]

In my controller am trying to iterate and store each object in that array

  foreach($request->get('products') as $product){
                   
          ItemOrder::where('purchase_order_id',$id)
           ->update([
                       
              'quantity_accepted'=>$product['quantity_accepted'],
                        
                       
        ]);
                    
                               
    }

i am only able to store one of the objects which is the last one



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3qC37ik
via IFTTT

Aucun commentaire:

Enregistrer un commentaire