<?php

declare(strict_types=1);

namespace ImovelZapAi\Sales\Infrastructure\Persistence\Eloquent;

use App\Models\User;
use Database\Factories\DealNoteFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;

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

    protected $table = 'sales_deal_notes';

    protected $fillable = [
        'tenant_id',
        'deal_id',
        'author_user_id',
        'body',
    ];

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

    public function deal(): BelongsTo
    {
        return $this->belongsTo(DealModel::class, 'deal_id');
    }

    public function author(): BelongsTo
    {
        return $this->belongsTo(User::class, 'author_user_id');
    }
}
