mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 23:13:59 +00:00
update rate history module
This commit is contained in:
+4
-3
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
|
||||
class CurrencyRateLog extends AbstractModel
|
||||
{
|
||||
protected $table = 'currency_rate_logs';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function currencyRate(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo(CurrencyRate::class, 'currency_rate_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user