<?php

declare(strict_types=1);

namespace App\Models;

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

final class Announcement extends Model
{
    protected $fillable = [
        'created_by',
        'title',
        'message',
        'target_audience',
        'scheduled_for',
        'sent_at',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'created_by' => 'integer',
            'scheduled_for' => 'datetime',
            'sent_at' => 'datetime',
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }

    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }
}
