mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-05-07 20:32:26 +00:00
38 lines
999 B
PHP
38 lines
999 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Service\CurrencyService;
|
|
use Brick\Money\Currency;
|
|
use Brick\Money\ISOCurrencyProvider;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class CurrencyController extends Controller
|
|
{
|
|
/**
|
|
* Get all currencies
|
|
*
|
|
* @response array{code: string, name: string, symbol: string}[]
|
|
*
|
|
* @operationId getCurrencies
|
|
*/
|
|
public function index(): JsonResponse
|
|
{
|
|
$currencyService = app(CurrencyService::class);
|
|
|
|
$currencies = array_values(array_map(
|
|
fn (Currency $currency): array => [
|
|
'code' => $currency->getCurrencyCode(),
|
|
'name' => $currency->getName(),
|
|
'symbol' => $currencyService->getCurrencySymbol($currency->getCurrencyCode()),
|
|
],
|
|
ISOCurrencyProvider::getInstance()->getAvailableCurrencies()
|
|
));
|
|
|
|
return response()->json($currencies);
|
|
}
|
|
}
|