Skip to content

Instantly share code, notes, and snippets.

Created October 18, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3910303 to your computer and use it in GitHub Desktop.
Save anonymous/3910303 to your computer and use it in GitHub Desktop.
InvoiceObjectCollection
// from lib/model/collection/InvoiceObjectCollection.php
class InvoiceObjectCollection extends PropelObjectCollection
{
/**
* Get the date range of invoices generated
*
* @param string $format
* @return type
*/
public function getDateRange($format = 'Y-m-d H:i:s')
{
return [
$this->getFirst()->getCreatedAt($format),
$this->getLast()->getCreatedAt($format)
];
}
/**
* Returns commission on ad spent in pennies
*
* @return int
*/
public function getCommissionOnSpend()
{
$amt = 0;
foreach($this as $invoice)
{
$amt += $invoice->getCommissionOnSpend();
}
return $amt;
}
}%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment