<?php

namespace App\Models;

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

class ServiceChat extends Model
{
    use HasFactory;

    public const PATH_PREFIX = 'public/chats';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'company_id',
        'user_id',
        'service_type',
    ];

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

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

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    public function getFolderPathAttribute()
    {
        return self::PATH_PREFIX . '/' . $this->id;
    }
}
