Skip to content
Advertisement

Laravel eloquent how to get the minimum value that is not NULL?

This is the code in my Product model to get the minimum price value (one product can have multiple price)

JavaScript

But it will return NULL rather than the smallest integer if there is a NULL.

Basically I want to achieve this:

[1, NULL, 2] returns 1

[1, NULL, 0] returns 0

Any suggestion would be appreciated.

Advertisement

Answer

I found filter, and it works now.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement