php - Laravel eloquent how to get the minimum value that is not NULL? -
this code in product model minimum price value (one product can have multiple price)
public function getlowestattribute () { return $this->prices->min('price'); } but return null rather smallest integer if there null.
basically want achieve this:
[1, null, 2] returns 1
[1, null, 0] returns 0
any suggestion appreciated.
have tried maybe
public function getlowestattribute () { return $this->prices->where('price','>=',0)->min('price'); }
Comments
Post a Comment