greatest/least expression
This commit is contained in:
@@ -48,7 +48,7 @@ class Expression implements WhereItem
|
||||
throw new RuntimeException("Expression can't be empty.");
|
||||
}
|
||||
|
||||
if (substr($expression, -1) === ':') {
|
||||
if (str_ends_with($expression, ':')) {
|
||||
throw new RuntimeException("Expression should not end with `:`.");
|
||||
}
|
||||
|
||||
@@ -653,6 +653,22 @@ class Expression implements WhereItem
|
||||
return self::composeFunction('ROUND', $number, $precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* 'GREATEST' function. A max value from a list of expressions.
|
||||
*/
|
||||
public static function greatest(Expression ...$expressionList): self
|
||||
{
|
||||
return self::composeFunction('GREATEST', ...$expressionList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 'LEAST' function. A min value from a list of expressions.
|
||||
*/
|
||||
public static function least(Expression ...$expressionList): self
|
||||
{
|
||||
return self::composeFunction('LEAST', ...$expressionList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 'AND' operator. Returns TRUE if all arguments are TRUE.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user