dimanche 1 janvier 2017

Merge fields laravel collections

I have two Laravel collections. Mi first collection called $custom_product:

Collection {#313 ▼
  #items: array:1 [▼
    0 => array:1 [▼
      "custom_description" => "insert description here"
    ]
  ]
}

And I have my other collection called $api_product:

Collection {#311 ▼
  #items: array:29 [▼
    "article_id" => 5570
    "active" => null
    "name" => "CORBATA POLIESTER"
    "detail" => "- Pesa: 43 gr."
    "constructor_name" => "gift"
    "stock_available" => true
    "stock" => null
    "prices" => array:6 [▶]
    "price_pvp" => 29.0
    "size" => "1410X100"
  ]
}

I want this result. The same collection but with the field custom_description added:

Collection {#311 ▼
  #items: array:29 [▼
    "article_id" => 5570
    "active" => null
    "custom_description" => "insert description here"//add this field
    "name" => "CORBATA POLIESTER"
    "detail" => "- Pesa: 43 gr."
    "constructor_name" => "gift"
    "stock_available" => true
    "stock" => null
    "prices" => array:6 [▶]
    "price_pvp" => 29.0
    "size" => "1410X100"
  ]
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire