*/ use HasFactory; use SyncsProjectTemplateOwnership; /** * @return array */ protected function casts(): array { return [ 'channel' => NotificationChannel::class, 'channel_configuration' => 'array', 'delivery_url' => 'encrypted', 'enabled' => 'boolean', 'event_type' => NotificationEventType::class, 'filters' => 'array', ]; } protected static function booted(): void { static::saving(function (self $notificationAction): void { $notificationAction->syncProjectTemplateOwnership(); }); } public function scopeEnabled(Builder $query): Builder { return $query->where('enabled', true); } public function deliveryLogs(): HasMany { return $this->hasMany(NotificationDeliveryLog::class) ->orderByDesc('created_at') ->orderByDesc('id'); } public function project(): BelongsTo { return $this->belongsTo(Project::class); } }