<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ExternalChatSession extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'meta' => 'array',
        'is_active' => 'boolean',
        'last_message_at' => 'datetime',
        'last_outbound_at' => 'datetime',
    ];

    public function messages()
    {
        return $this->hasMany(ExternalChatMessage::class);
    }

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