<?php

namespace App\Models;

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

class MensagensChat extends Model
{
    use HasFactory;
    use SoftDeletes;
    protected $dates = ['deleted_at'];
    protected $table="mensagenschats";
    protected $primariKey="id";
    protected $fillable = ['user_to','user_from','mensagem','ficheiro','nomeoriginal',
                            'tipomensagem','estadomensagem','estado','tamanhoarquivo'];

    public function getOrigem()
    {
         return $this->hasOne(User::class, 'id', 'user_from');
    }
    
     public function getDestinatario()
    {
        return $this->hasOne(User::class, 'id', 'user_to');
    }

}
