Advanced operations with Collection:where in Laravel 5.2

Laravel 5.2 Collection:where()

 

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:

In e-commerce application we have to filter the records which meet multiple criteria like brand, vendor, size, color, price, sorting, searching and so on.

Lets say we have to find product records having category shoes, brand_name Puma, color white, price between 2000 and 4000,

In above code snippet we are filtering records in random order and records are ordered by $key and $value specified. Collection records can be paginated by using paginate() method.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.