feat: 增强环境配置与开发服务,支持局域网访问及币种管理
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Currency;
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
final class AdminCurrencyIndexController extends Controller
|
||||
{
|
||||
public function __invoke(): JsonResponse
|
||||
{
|
||||
$items = Currency::query()
|
||||
->orderByDesc('is_enabled')
|
||||
->orderByDesc('is_bettable')
|
||||
->orderBy('code')
|
||||
->get()
|
||||
->map(fn (Currency $currency): array => $this->serializeCurrency($currency))
|
||||
->all();
|
||||
|
||||
return ApiResponse::success(['items' => $items]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function serializeCurrency(Currency $currency): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) $currency->id,
|
||||
'code' => $currency->code,
|
||||
'name' => $currency->name,
|
||||
'decimal_places' => (int) $currency->decimal_places,
|
||||
'is_enabled' => (bool) $currency->is_enabled,
|
||||
'is_bettable' => (bool) $currency->is_bettable,
|
||||
'created_at' => $currency->created_at?->toIso8601String(),
|
||||
'updated_at' => $currency->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user