Answers for "how to filter collection in larael"

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

filter collection (laravel)

$itemCollection = collect($contacts);
$filtered = $itemCollection->filter(function($item) use ($search) {
    return stripos($item['username'],$search) !== false;
});
Posted by: Guest on June-12-2021

Code answers related to "how to filter collection in larael"

Browse Popular Code Answers by Language