/** * {@inheritDoc} */ public function render() { $dataProvider = new DataProvider(); $budgetControlService = new BudgetControlService(new PurchaseService($dataProvider), new Goalr()); $monthlyGoal = MonthlyGoal::query()->mine()->currentMonth()->first(); if ($monthlyGoal) { $todayBudget = new Currency($budgetControlService->getDailyMonthlyBudget($monthlyGoal, \BackendAuth::getUser())); $todayBudget->setFormat('{number}'); $todaySpent = new Currency(Purchase::calcAmountByPeriod(new \DateTime(), new \DateTime(), \BackendAuth::getUser()->id)); $todaySpent->setFormat('{number}'); $this->vars['todaySpent'] = $todaySpent; $this->vars['todayBudget'] = $todayBudget; return $this->makePartial('dailybudget'); } else { return $this->makePartial('no_monthly_goal'); } }
/** * @param int[] $monthly_goal_ids * * @return MonthlyGoal[] */ public function findMonthlyGoalByIds($monthly_goal_ids) { return MonthlyGoal::query()->whereIn($monthly_goal_ids)->get(); }