diff --git a/app/Classes/Modules/Currencies/ControllersLogic/History/ListCurrencyRateHistoryLogic.php b/app/Classes/Modules/Currencies/ControllersLogic/History/ListCurrencyRateHistoryLogic.php index f1fb4f10..c36eebf6 100644 --- a/app/Classes/Modules/Currencies/ControllersLogic/History/ListCurrencyRateHistoryLogic.php +++ b/app/Classes/Modules/Currencies/ControllersLogic/History/ListCurrencyRateHistoryLogic.php @@ -64,14 +64,15 @@ class ListCurrencyRateHistoryLogic extends AbstractControllerLogic $rate_filter['currency_id'] = $filterArray->currency_id; $rate_filter['service_id'] = $filterArray->service_id; - $currency_rate = $this->fetchesRate->execute( + $currency_rate_ids = $this->fetchesRate->execute( [ 'currency_id' => $filterArray->currency_id, 'service_id' => $filterArray->service_id, ] - )->first(); + )->pluck('id')->toArray(); - $query = CurrencyRateLog::where('currency_rate_id', $currency_rate->id)->get(); + // todo: add in date filters + $query = CurrencyRateLog::whereIn('currency_rate_id', $currency_rate_ids)->get(); return $this->collectionResponse(CurrencyRateLogResource::collection($query)); } diff --git a/app/Http/Resources/CurrencyRateLogResource.php b/app/Http/Resources/CurrencyRateLogResource.php index 436d8359..f8560dd8 100644 --- a/app/Http/Resources/CurrencyRateLogResource.php +++ b/app/Http/Resources/CurrencyRateLogResource.php @@ -14,10 +14,13 @@ class CurrencyRateLogResource extends JsonResource */ public function toArray($request) { + $currencyRate = $this->currencyRate; + return [ 'currency_rate_id' => $this->currency_rate_id, 'rate' => $this->selling, 'created_at' => $this->created_at->format('d-m-Y'), + 'payment_method_type' => $currencyRate->payment_method_type, ]; } } diff --git a/app/Models/CurrencyRateLog.php b/app/Models/CurrencyRateLog.php index 38130956..85b0eecf 100644 --- a/app/Models/CurrencyRateLog.php +++ b/app/Models/CurrencyRateLog.php @@ -1,10 +1,19 @@ BelongsTo(CurrencyRate::class, 'currency_rate_id', 'id'); + } }