<?php
 namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasMany; class NotificationTemplate extends CommunicationTemplate { protected $table = 'communication_templates'; protected static function booted(): void { parent::booted(); static::addGlobalScope('channel', fn (Builder $q) => $q->whereIn('channel', self::ADMIN_CHANNELS)); static::creating(function (self $model) { if (! in_array($model->channel, self::ADMIN_CHANNELS, true)) { throw new \InvalidArgumentException( "NotificationTemplate yalnız admin kanallarını kabul eder; verilen: " . var_export($model->channel, true) ); } }); } public function contents(): HasMany { return $this->hasMany(NotificationTemplateContent::class, 'template_id'); } } 