Пример #1
0
 /**
  * @param BudgetRepositoryInterface $repository
  * @param Budget                    $budget
  * @param LimitRepetition           $repetition
  *
  * @return \Illuminate\View\View
  */
 public function show(BudgetRepositoryInterface $repository, Budget $budget, LimitRepetition $repetition = null)
 {
     if (!is_null($repetition->id) && $repetition->budgetLimit->budget->id != $budget->id) {
         $message = 'Invalid selection.';
         return view('error', compact('message'));
     }
     $journals = $repository->getJournals($budget, $repetition);
     if (is_null($repetition->id)) {
         $start = $repository->firstActivity($budget);
         $end = new Carbon();
         $set = $budget->limitrepetitions()->orderBy('startdate', 'DESC')->get();
         $subTitle = e($budget->name);
     } else {
         $start = $repetition->startdate;
         $end = $repetition->enddate;
         $set = new Collection([$repetition]);
         $subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
     }
     $spentArray = $repository->spentPerDay($budget, $start, $end);
     $limits = new Collection();
     /** @var LimitRepetition $entry */
     foreach ($set as $entry) {
         $entry->spent = $this->getSumOfRange($entry->startdate, $entry->enddate, $spentArray);
         $limits->push($entry);
     }
     $journals->setPath('/budgets/show/' . $budget->id);
     return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
 }