<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ClientPaymentMethod extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'client_id',
        'token',
        'card_number',
        'holder_name',
        'expiration',
        'cvv',
        'card_name',
        'brand',
        'last_four_digits',
        'is_active',
    ];

    protected $casts = [
        'token' => 'encrypted',
        'card_number' => 'encrypted',
        'cvv' => 'encrypted',
        'is_active' => 'boolean',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];

    protected $hidden = [
        'token',
        'card_number',
        'cvv',
    ];

    public function client(): BelongsTo
    {
        return $this->belongsTo(Client::class);
    }
}
