Pages::getMin($field[,$addEmpty])
Version 3.8
Get the smallest value
Version 3.8
Get the smallest value
Method will return a Field object, if given parameter is a field name. Otherwise returns decimal.
Float
Get Open Invoice that has the smallest total amount:
$min = $this->get('pages','invoice')
->addWhere('status','Open')
->getMin('total_amount');
This method is shorthand for:
foreach ( $this->get('pages','Invoice')->addWhere('status','Open') as $Invoice ){
if ( $Invoice->total_amount->isUnder($value) ){
$value = $Invoice->total_amount;
}
}
Get Open Invoice that has the smallest total amount that is not 0:
$min = $this->get('pages','Invoice')->addWhere('status','Open')->getMin('total_amount',false);
Get Open Invoice that had the smallest amount before discount:
$min = $this->get('pages','Invoice')->addWhere('status','Open')->getMin('total_amount*(100+discount_percent)/100');
DateField: The oldest invoice that is Open
$min = $this->get('pages','Invoice')->addWhere('status','Open')->getMin('invoice_date');
SelectionField: The first status of customers Invoice:
$min = $this->get('pages','Invoice')->addWhere('customer',$customerId)->getMin('status');