Answers for "eloquent filter all collection"

PHP
2

Filtering Eloquent collection data with filter

$filtered_collection = $collection->filter(function ($item) {
    return $item->isDog();
})->values();
Posted by: Guest on October-07-2021
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

Browse Popular Code Answers by Language