<?php
 namespace App\Models; use Database\Factories\PostFactory; use Illuminate\Database\Eloquent\Attributes\UseFactory; use Illuminate\Database\Eloquent\Builder; #[UseFactory(PostFactory::class)] class Announcement extends Post { protected $table = 'posts'; protected static function booted(): void { static::addGlobalScope('type_announcement', function (Builder $query) { $query->where('type', 'announcement'); }); static::creating(function (self $model) { $model->type = 'announcement'; }); } public function subtypeBadge(): array { return match ($this->subtype) { 'security' => ['color' => 'danger', 'icon' => 'fa-shield-alt', 'label_key' => 'security'], 'maintenance' => ['color' => 'warning', 'icon' => 'fa-tools', 'label_key' => 'maintenance'], 'update' => ['color' => 'info', 'icon' => 'fa-sync', 'label_key' => 'update'], default => ['color' => 'secondary', 'icon' => 'fa-bullhorn', 'label_key' => 'general'], }; } } 