Skip to content

Instantly share code, notes, and snippets.

@oojacoboo
Created May 28, 2013 05:33
Show Gist options
  • Select an option

  • Save oojacoboo/5660667 to your computer and use it in GitHub Desktop.

Select an option

Save oojacoboo/5660667 to your computer and use it in GitHub Desktop.
/**
* Gets all the tenants associated with this unit that are current on their lease
* @param bool $includeMovedOutWithBalanceDue
* @return array|PropelCollection
*/
function getCurrentTenants($includeMovedOutWithBalanceDue = false) {
//using array filter to pull cached tenant array from object for speed
return array_filter($this->getTenants()->getData(), function($tenant) use ($includeMovedOutWithBalanceDue) {
return ((!$tenant->getMoveOutDate() || $tenant->getMoveOutDate("U") > time())
|| (!$includeMovedOutWithBalanceDue || $tenant->getBalance() < 0)
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment