<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ChatMessage extends Model
{
    protected $fillable = [
        'room_id',
        'user_id',
        'message',
        'user_name',
        'is_deleted',
        'deleted_at',
        // Profanity filtering
        'is_flagged',
        'original_message',
        // Bot message
        'is_bot_message',
        'bot_sources',
        'bot_query',
    ];

    protected $casts = [
        'is_deleted'     => 'boolean',
        'deleted_at'     => 'datetime',
        'is_flagged'     => 'boolean',
        'is_bot_message' => 'boolean',
        'bot_sources'    => 'array',
    ];

    public function room()
    {
        return $this->belongsTo(ChatRoom::class, 'room_id');
    }

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