<?php

namespace App\Models;

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

class SupportMessage extends Model
{
    protected $fillable = [
        'ticket_id',
        'sender_id',
        'is_platform_reply',
        'body',
        'read_by_org_at',
        'read_by_admin_at',
    ];

    protected function casts(): array
    {
        return [
            'is_platform_reply' => 'boolean',
            'read_by_org_at'    => 'datetime',
            'read_by_admin_at'  => 'datetime',
        ];
    }

    public function ticket(): BelongsTo
    {
        return $this->belongsTo(SupportTicket::class, 'ticket_id');
    }

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