Update find methods to return null

This commit is contained in:
James Cole
2018-02-16 15:19:19 +01:00
parent 28b00f6507
commit 33db99ffd3
16 changed files with 142 additions and 34 deletions

View File

@@ -129,6 +129,18 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return $currency;
}
/**
* Find by currency code, return NULL if unfound.
*
* @param string $currencyCode
*
* @return TransactionCurrency|null
*/
public function findByCodeNull(string $currencyCode): ?TransactionCurrency
{
return TransactionCurrency::where('code', $currencyCode)->first();
}
/**
* Find by currency name.
*
@@ -163,6 +175,21 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return $currency;
}
/**
* Find by ID, return NULL if not found.
*
* @param int $currencyId
*
* @return TransactionCurrency|null
*/
public function findNull(int $currencyId): ?TransactionCurrency
{
/** @var TransactionCurrency $res */
$res = TransactionCurrency::find($currencyId);
return $res;
}
/**
* @return Collection
*/