/** * @param BudgetRepositoryInterface $repository * @param Budget $budget * @param LimitRepetition $repetition * * @return View * @throws FireflyException */ public function showWithRepetition(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition) { if ($repetition->budgetLimit->budget->id != $budget->id) { throw new FireflyException('This budget limit is not part of this budget.'); } $start = $repetition->startdate; $end = $repetition->enddate; $page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page')); $pageSize = Preferences::get('transactionPageSize', 50)->data; $offset = ($page - 1) * $pageSize; $journals = $repository->journalsInPeriod(new Collection([$budget]), new Collection(), $start, $end); $count = $journals->count(); $journals = $journals->slice($offset, $pageSize); $journals = new LengthAwarePaginator($journals, $count, $pageSize); $subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]); $journals->setPath('/budgets/show/' . $budget->id . '/' . $repetition->id); $repetition->spent = $repository->spentInPeriod(new Collection([$budget]), new Collection(), $repetition->startdate, $repetition->enddate); $limits = new Collection([$repetition]); return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); }