<?php

namespace App\Domain\Notification\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NotificationPreference extends Model
{
    protected $table = 'notification_preferences';

    protected $fillable = [
        // academy_id since S1's tenancy repair: this is a tenant table and was
        // the only one of four still writing rows that belonged to no academy.
        'academy_id',
        'user_id',
        'event_type',
        'channel_email',
        'channel_sms',
        'channel_in_app',
        'channel_push',
        'digest_mode',
        'digest_time',
    ];

    protected $casts = [
        'channel_email' => 'boolean',
        'channel_sms' => 'boolean',
        'channel_in_app' => 'boolean',
        'channel_push' => 'boolean',
        'digest_mode' => 'boolean',
    ];

    // Relationships

    public function user(): BelongsTo
    {
        return $this->belongsTo(\App\Models\User::class);
    }
}
