Answers for "laravel collection where function"

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
1

laravel collection methods

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

$collection->each(function($item){
    return $item*$item;
});

// [1,4,9,16]
Posted by: Guest on September-06-2020
0

collection methods laravel

$collection->each(function ($item, $key) {
    hj
});
Posted by: Guest on January-13-2021

Code answers related to "laravel collection where function"

Browse Popular Code Answers by Language