This commit is contained in:
2021-03-19 22:49:09 -03:00
parent ec44b0281e
commit 99c18cb871
8 changed files with 45 additions and 11 deletions

View File

@ -115,4 +115,19 @@ class Currencies {
}
return $this->withJson($response, $output);
}
public function latestValue(Request $request, Response $response, ModelFactory $factory, $currency_id): Response {
$currency = $factory->find(Currency::class)->one($currency_id);
$output = [
'get_data' => compact('currency_id'),
'currency' => null,
'value' => null
];
if ($currency) {
$output['currency'] = $currency->asArray();
if ($currency->latest()) {
$output['value'] = $currency->latest()->asArray();
}
}
return $this->withJson($response, $output);
}
}