<?php

namespace App\Models;

use App\Enum\Esign\RedressRole;
use App\Trait\BelongsToSolicitor;
use Illuminate\Database\Eloquent\Model;

/**
 * A contract type belongs to a solicitor — each firm has its own set, each
 * optionally mapped to a Fintrixor template id for e-signature. A contract may
 * also carry a Redress annex `redress_role`, in which case it fans out into one
 * document per care setting when sent (see EsignService::createDraftRequest()).
 */
class Contract extends Model
{
    use BelongsToSolicitor;

    public $fillable = [
        'solicitor_id',
        'name',
        'requires_preview',
        'fintrixor_template_id',
        'redress_role',
    ];

    public $casts = [
        'requires_preview' => 'boolean',
        'redress_role' => RedressRole::class,
    ];

    public function isPart1Annex(): bool
    {
        return $this->redress_role === RedressRole::PART1_ANNEX;
    }

    public function isPart2Annex(): bool
    {
        return $this->redress_role === RedressRole::PART2_ANNEX;
    }
}
