<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Announcement extends Model
{
    protected $fillable = [
        'author_id', 'message', 'target_group', 'priority', 'published_at',
    ];

    protected $casts = ['published_at' => 'datetime'];

    public function author()
    {
        return $this->belongsTo(User::class, 'author_id');
    }

    public function priorityColor(): string
    {
        return match ($this->priority) {
            'urgent' => '#DC2626',
            'high'   => '#D97706',
            default  => '#0D9488',
        };
    }

    public function priorityLabel(): string
    {
        return ucfirst($this->priority);
    }
}
