<?php

namespace App\Models;

use App\Models\Concerns\BelongsToMerchant;
use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    use BelongsToMerchant;

    protected $fillable = [
        'public_id',
        'merchant_id',
        'environment',
        'reference_id',
        'name',
        'email',
        'phone',
        'status',
        'billing_address',
        'shipping_address',
        'metadata',
        'archived_at',
    ];

    protected function casts(): array
    {
        return [
            'billing_address' => 'array',
            'shipping_address' => 'array',
            'metadata' => 'array',
            'archived_at' => 'datetime',
        ];
    }

    public function merchant()
    {
        return $this->belongsTo(Merchant::class);
    }

    public function invoices()
    {
        return $this->hasMany(Invoice::class);
    }
}
