<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class ClientPaymentMethodResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'               => $this->id,
            'client_id'        => $this->client_id,
            'gateway_card_id'  => $this->gateway_card_id,
            'holder_name'      => $this->holder_name,
            'expiration'       => $this->expiration,
            'card_name'        => $this->card_name,
            'brand'            => $this->brand,
            'last_four_digits' => $this->last_four_digits,
            'card_number'      => $this->last_four_digits ? '**** **** **** '.$this->last_four_digits : null,
            'is_active'        => $this->is_active,
            'created_at'       => $this->created_at?->format('Y-m-d H:i'),
            'updated_at'       => $this->updated_at?->format('Y-m-d H:i'),
        ];
    }
}
