<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TemplateSection extends Model
{
    use HasFactory;

    protected $fillable = ['template_id', 'title', 'order'];

    public function template()
    {
        return $this->belongsTo(ContractTemplate::class, 'template_id');
    }

    public function variations()
    {
        return $this->hasMany(ContractSections::class)->orderBy('order', 'asc');;
    }

    public function sectionRules()
    {
        return $this->belongsToMany(SectionRule::class, 'section_rule_template_section')
                    ->withTimestamps();
    }
}
