<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Announcement extends Model
{
    protected $fillable = [
        'user_id',
        'title',
        'content',
        'priority',
        'is_pinned',
    ];

    protected $casts = [
        'is_pinned' => 'boolean',
    ];

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

    // Warna badge per prioritas
    public function priorityColor(): string
    {
        return match ($this->priority) {
            'penting'   => 'role-operator',
            'mendesak'  => 'role-kepsek',
            default     => 'role-guru',
        };
    }

    public function priorityIcon(): string
    {
        return match ($this->priority) {
            'penting'   => 'fa-triangle-exclamation',
            'mendesak'  => 'fa-circle-exclamation',
            default     => 'fa-circle-info',
        };
    }
}
