<?php

namespace App\Models;

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

class Message extends BaseModel
{
    use HasFactory;

    protected $table = 'message';

    public function fromUser(){
        return $this->hasOne(User::class, 'id', 'from_user_id');
    }

    public function toUser(){
        return $this->hasOne(User::class, 'id', 'to_user_id');
    }

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

}
