<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class InternalMessage extends Model
{

    protected $table = 'internal_message';

    public function getRouteKeyName()
    {
        return 'uid';
    }

    public function fromPro()
    {
        return $this->hasOne(Pro::class, 'id', 'from_pro_id');
    }

    public function toPro()
    {
        return $this->hasOne(Pro::class, 'id', 'to_pro_id');
    }

    public function regardingClient()
    {
        return $this->hasOne(Client::class, 'id', 'regarding_client_id');
    }

    public function regardingCompany()
    {
        return $this->hasOne(Client::class, 'id', 'regarding_company_id');
    }

    public function attachments()
    {
        return $this->hasMany(InternalMessageAttachment::class, 'internal_message_id', 'id');
    }

    public function videoFile()
    {
        return $this->hasOne(SystemFile::class, 'id', 'message_video_file_id');
    }
}
