Answers for "add array to another array in laravel collection"

PHP
1

add array to another array in laravel collection

$collection = collect(['product_id' => 1, 'price' => 100]);
 
$merged = $collection->merge(['price' => 200, 'discount' => false]);
 
$merged->all();
 
// ['product_id' => 1, 'price' => 200, 'discount' => false]
Posted by: Guest on March-02-2022

Code answers related to "add array to another array in laravel collection"

Browse Popular Code Answers by Language