<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasMany; class EmailTemplate extends CommunicationTemplate { protected $table = 'communication_templates'; protected static function booted(): void { parent::booted(); static::addGlobalScope('channel', fn (Builder $q) => $q->where('channel', 'email')); static::creating(function (self $model) { $model->channel = 'email'; $model->is_html ??= true; }); } public function contents(): HasMany { return $this->hasMany(EmailTemplateContent::class, 'template_id'); } } 