<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PaymentMethod extends Model
{
    protected $fillable = ['business_id', 'name', 'type', 'account_number', 'bank_name', 'is_active'];
    protected $casts = ['is_active' => 'boolean'];

    public function toArray(): array
    {
        $a = parent::toArray();
        $a['businessId']    = $a['business_id']    ?? null;
        $a['accountNumber'] = $a['account_number'] ?? null;
        $a['bankName']      = $a['bank_name']      ?? null;
        $a['isActive']      = (bool) ($a['is_active'] ?? true);
        return $a;
    }

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