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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -