/** * Returns the report's criteria * * @param ReportConfiguration $configuration * * @return Criteria */ protected function getCriteria(ReportConfiguration $configuration) { $criteria = new Criteria(); $criteria->where($criteria->expr()->gte('createdAt', $configuration->getStartDate())); $criteria->andWhere($criteria->expr()->lte('createdAt', $configuration->getEndDate())); return $criteria; }
/** * @return array */ protected function prepareValues() { $periods = $this->configuration->getPeriods(); $values = []; foreach ($periods as $period) { $values[$period->format($this->configuration->getGroupByDateFormat())] = ['value' => 0, 'meta' => $period->format($this->configuration->getDatePresentationFormat())]; } return $values; }
/** * Filters a collection to get only current items * * @param Collection $collection * * @return Collection */ protected function filterCurrentItems(Collection $collection) { $endDate = new DateTime(); $format = $this->configuration->getGroupByDateFormat(); $identifier = $endDate->format($format); return $collection->filter(function (ReportRow $row) use($identifier) { return $row->getIdentifier() === $identifier; }); }