<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    protected $fillable = [
        'name', 'email', 'phone', 'subject', 'message', 'status'
    ];

    protected $casts = [
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    public function getStatusBadgeAttribute()
    {
        return match($this->status) {
            'new' => '<span class="bg-blue-100 text-blue-800 px-2 py-1 rounded-full text-xs">New</span>',
            'read' => '<span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-xs">Read</span>',
            'replied' => '<span class="bg-purple-100 text-purple-800 px-2 py-1 rounded-full text-xs">Replied</span>',
            default => '<span class="bg-gray-100 text-gray-800 px-2 py-1 rounded-full text-xs">Unknown</span>'
        };
    }
}
