Move code to repository.

This commit is contained in:
James Cole
2018-02-17 10:47:32 +01:00
parent c6da990748
commit 7bbfb692de
5 changed files with 36 additions and 9 deletions

View File

@@ -163,6 +163,24 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return new PiggyBank();
}
/**
* Get current amount saved in piggy bank.
*
* @param PiggyBank $piggyBank
*
* @return string
*/
public function getCurrentAmount(PiggyBank $piggyBank): string
{
/** @var PiggyBankRepetition $rep */
$rep = $piggyBank->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
if (null === $rep) {
return '0';
}
return strval($rep->currentamount);
}
/**
* @param PiggyBank $piggyBank
*