<?php

namespace App\Domains\Admin\Controllers;

use App\Models\AvailablePaymentMethod;
use App\Resources\AvailablePaymentMethodResource;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class TenantPaymentMethodsGetController extends CommonController
{
    public function __invoke(Request $request): JsonResponse
    {
        return response()->json([
            'paymentMethods' => AvailablePaymentMethod::all()
                ->map(fn (AvailablePaymentMethod $method) => new AvailablePaymentMethodResource($method)->toArray($request)),
            'saveEndpoint' => '/api/v1/admin/tenant/payment-methods',
        ]);
    }
}
