Expand tests and API code.

This commit is contained in:
James Cole
2018-02-18 10:31:15 +01:00
parent 6cda9f2900
commit eb0da038fb
28 changed files with 1171 additions and 172 deletions

View File

@@ -163,6 +163,26 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return new PiggyBank();
}
/**
* Find by name or return NULL.
*
* @param string $name
*
* @return PiggyBank|null
*/
public function findByName(string $name): ?PiggyBank
{
$set = $this->user->piggyBanks()->get(['piggy_banks.*']);
/** @var PiggyBank $piggy */
foreach ($set as $piggy) {
if ($piggy->name === $name) {
return $piggy;
}
}
return null;
}
/**
* Get current amount saved in piggy bank.
*