/** * Return the chart data you want to return based on the ChartConfig * * @param User $user * @param ActivityUsageRepository|StorageUsageRepository $repository * @param ChartConfig $chartConfig * @return mixed */ public function getChartUsage(User $user, $repository, ChartConfig $chartConfig) { if ($user->isAdminUser($user->getSignedInUsername())) { $data = $repository->findAllPerMonth(); } else { $data = $repository->findAllPerMonth($chartConfig->getUsername()); } return $data; }
/** * Return a collection off 1 month ago based on the username supplied * * @param string $username * @return ActivityDayCollection */ private function getCollectionByUsername($username) { $created = new \DateTime("-1 month"); $data = $this->repository->findAfterCreatedByUsername($created, $username); $collection = new ActivityDayCollection(); foreach ($data as $activityUsage) { $collection->add($activityUsage); } return $collection; }