<?php

namespace App\Models;

use App\Enums\ClientOrigin;
use App\Enums\Currency;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Client extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'origin',
        'country',
        'currency_default',
        'hourly_rate',
        'contact_name',
        'contact_email',
        'contact_phone',
        'notes',
    ];

    protected function casts(): array
    {
        return [
            'origin'           => ClientOrigin::class,
            'currency_default' => Currency::class,
            'hourly_rate'      => 'decimal:2',
        ];
    }

    public function sales(): HasMany
    {
        return $this->hasMany(Sale::class);
    }

    public function renewals(): HasMany
    {
        return $this->hasMany(Renewal::class);
    }
}
