Answers for "laravel collection put"

PHP
4

collection laravel filter

$collection = collect([1, 2, 3, 4]);

$filtered = $collection->filter(function ($value, $key) {
    return $value > 2;
});

$filtered->all();

// [3, 4]
Posted by: Guest on November-17-2020
2

add to collection laravel

$item = collect();
$item->push($product);
Posted by: Guest on November-24-2020
0

laravel collection put

$collection = collect(['product_id' => 1, 'name' => 'Desk']);

$collection->put('price', 100);

$collection->all();

// ['product_id' => 1, 'name' => 'Desk', 'price' => 100]
Posted by: Guest on July-24-2021

Code answers related to "laravel collection put"

Browse Popular Code Answers by Language