<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Stancl\Tenancy\Database\Concerns\CentralConnection;

class NotificationTemplate extends Model
{
    use CentralConnection;
    use HasFactory;

    protected $fillable = [
        'is_published',
        'title',
        'type',
        'field_map',
        'validation',
        'config',
    ];

    protected $casts = [
        'field_map' => 'array',
        'validation' => 'array',
        'config' => 'array',
        'is_published' => 'bool',
    ];

    public function scopePublished(Builder $query): void
    {
        $query->where('is_published', 1);
    }
}
