/** * Do we have any unprocessed jobs scheduled for anytime in the future? * @return boolean */ public function hasJobs() { $count = 0; Collection::model('\\Virge\\Cron\\Model\\Job')->filter(function () { Filter::isNull('started_on'); })->count($count); return $count > 0; }
/** * Find a entity by filter callback * @param callable $filter * @param int $limit * @param int $start * @return array */ public static function find($filter = NULL, $limit = 25, $start = 0) { if (is_callable($filter)) { $collection = Collection::model(get_called_class())->filter($filter); } else { $collection = Collection::model(get_called_class())->filter(function () use($filter) { Filter::start(); Filter::eq('id', $filter); Filter::end(); }); } $collection->setLimit($limit); $collection->setStart($start); $collection = $collection->get(); $results = array(); while ($row = $collection->fetch()) { $results[] = $row; } if (empty($results)) { return array(); } return $results; }