Expand API and routes.

This commit is contained in:
James Cole
2018-12-08 21:26:20 +01:00
parent 3b15415a1b
commit 05b0425929
27 changed files with 686 additions and 516 deletions

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Log;
@@ -341,6 +342,25 @@ class CurrencyRepository implements CurrencyRepositoryInterface
return null;
}
/**
* Return a list of exchange rates with this currency.
*
* @param TransactionCurrency $currency
*
* @return Collection
*/
public function getExchangeRates(TransactionCurrency $currency): Collection
{
/** @var CurrencyExchangeRate $rate */
return $this->user->currencyExchangeRates()
->where(
function (Builder $query) use ($currency) {
$query->where('from_currency_id', $currency->id);
$query->orWhere('to_currency_id', $currency->id);
}
)->get();
}
/**
* @param User $user
*/