/** * Shows all bills and whether or not theyve been paid this month (pie chart). * * @param BillRepositoryInterface $repository * * @return \Symfony\Component\HttpFoundation\Response */ public function frontpage(BillRepositoryInterface $repository) { $start = Session::get('start', Carbon::now()->startOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth()); $cache = new CacheProperties(); // chart properties for cache: $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('bills'); $cache->addProperty('frontpage'); if ($cache->has()) { return Response::json($cache->get()); // @codeCoverageIgnore } $set = $repository->getBillsForChart($start, $end); // optionally expand this set with credit card data $set = $repository->getCreditCardInfoForChart($set, $start, $end); $paid = $set->get('paid'); $unpaid = $set->get('unpaid'); // build chart: $data = $this->generator->frontpage($paid, $unpaid); $cache->store($data); return Response::json($data); }