transactions()->leftJoin( 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount') ); return $balance; } /** * @param $boolean * * @return string */ public function boolString($boolean) { if ($boolean === true) { return 'BOOLEAN TRUE'; } if ($boolean === false) { return 'BOOLEAN FALSE'; } return 'NO BOOLEAN: ' . $boolean; } /** * @param \PiggyBank $piggyBank * @param \PiggyBankRepetition $repetition * * @return int */ public function percentage(\PiggyBank $piggyBank, \PiggyBankRepetition $repetition) { $pct = $repetition->currentamount / $piggyBank->targetamount * 100; if ($pct > 100) { return 100; } else { return floor($pct); } } public function removeEmptyBudgetLimits() { $user = \Auth::user(); if ($user) { \BudgetLimit::where('amount', 0)->delete(); } } }