Exemplo n.º 1
0
 /**
  * @param CategoryRepositoryInterface $repository
  * @param Category                    $category
  *
  * @return \Illuminate\View\View
  */
 public function show(CategoryRepositoryInterface $repository, Category $category)
 {
     $hideCategory = true;
     // used in list.
     $page = intval(Input::get('page'));
     $set = $repository->getJournals($category, $page);
     $count = $repository->countJournals($category);
     $journals = new LengthAwarePaginator($set, $count, 50, $page);
     $journals->setPath('categories/show/' . $category->id);
     return view('categories.show', compact('category', 'journals', 'hideCategory'));
 }
Exemplo n.º 2
0
 /**
  * @param CategoryRepositoryInterface $repository
  * @param Category                    $category
  *
  * @return \Illuminate\View\View
  */
 public function show(CategoryRepositoryInterface $repository, Category $category)
 {
     $hideCategory = true;
     // used in list.
     $page = intval(Input::get('page'));
     $set = $repository->getJournals($category, $page);
     $count = $repository->countJournals($category);
     $subTitle = $category->name;
     $journals = new LengthAwarePaginator($set, $count, 50, $page);
     $journals->setPath('categories/show/' . $category->id);
     // list of ranges for list of periods:
     // oldest transaction in category:
     $start = $repository->getFirstActivityDate($category);
     $range = Preferences::get('viewRange', '1M')->data;
     $start = Navigation::startOfPeriod($start, $range);
     $end = Navigation::endOfX(new Carbon(), $range);
     $entries = new Collection();
     // chart properties for cache:
     $cache = new CacheProperties();
     $cache->addProperty($start);
     $cache->addProperty($end);
     $cache->addProperty('category-show');
     $cache->addProperty($category->id);
     if ($cache->has()) {
         $entries = $cache->get();
     } else {
         while ($end >= $start) {
             $end = Navigation::startOfPeriod($end, $range);
             $currentEnd = Navigation::endOfPeriod($end, $range);
             // here do something.
             $spent = $repository->spentInPeriod($category, $end, $currentEnd);
             $earned = $repository->earnedInPeriod($category, $end, $currentEnd);
             $dateStr = $end->format('Y-m-d');
             $dateName = Navigation::periodShow($end, $range);
             $entries->push([$dateStr, $dateName, $spent, $earned]);
             $end = Navigation::subtractPeriod($end, $range, 1);
         }
         $cache->store($entries);
     }
     return view('categories.show', compact('category', 'journals', 'entries', 'hideCategory', 'subTitle'));
 }