In Laravel, you can use Collection:where() to filter records which meet particular criteria. The where method uses strict comparisons when checking item values. A simple scenario of using where() method:
|
$collection = collect([ ['product' => 'Belt', 'price' => 200], ['product' => 'Suit', 'price' => 6000], ['product' => 'Shoe', 'price' => 1500], ['product' => 'Blazer', 'price' => 1000], ]); $filtered = $collection->where('price', '>', 1499); $filtered->all(); /* [ ['product' => 'Suit', 'price' => 6000], ['product' => 'Shoe', 'price' => 1500], ] */ |
In e-commerce application we have to filter...