<?php

namespace App\Domain\Communication\Models;

use App\Domain\Communication\Enums\NotificationChannel;
use App\Support\Concerns\HasUuid;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;

/** Which channels someone is willing to hear from (§57). */
class NotificationPreference extends Model
{
    use HasUuid;

    protected $guarded = ['id', 'uuid'];

    protected function casts(): array
    {
        return [
            'channel' => NotificationChannel::class,
            'is_enabled' => 'boolean',
        ];
    }

    public function owner(): MorphTo
    {
        return $this->morphTo();
    }
}
