<?php

declare(strict_types=1);

namespace ImovelZapAi\Sales\Infrastructure\Persistence\Eloquent;

use Database\Factories\DealTagFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;

class DealTagModel extends Model
{
    use BelongsToTenant;
    use HasFactory;
    use HasUuidPrimaryKey;

    protected $table = 'sales_deal_tags';

    protected $fillable = [
        'tenant_id',
        'name',
        'color',
    ];

    protected static function newFactory(): DealTagFactory
    {
        return DealTagFactory::new();
    }

    public function deals(): BelongsToMany
    {
        return $this->belongsToMany(DealModel::class, 'sales_deal_tag_deal', 'tag_id', 'deal_id');
    }
}
