Skip to content
Advertisement

How to get two minimum values ​from a price column (database). [Laravel]

I’m doing an online store and I have a “sale” section. In this section I want to place two products with the minimum price. I can get one product using the min () function, but I do not understand how to get two minimum values ​​from the database.Thank you in advance.

Advertisement

Answer

you can use it like the for getting two minimum values

$sale = Sale::orderBy('price','asc')->take(2)->get();
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement