edms2023/app/RemoteTransfer.php

51 lines
1.0 KiB
PHP

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RemoteTransfer extends Model
{
protected $fillable = ['receipt', 'login', 'direction', 'status', 'send_at', 'workflow_document_id', 'content', 'document_name', 'place_of_the_documents', 'contact_id'];
public function contact()
{
return $this->belongsTo(Contact::class, 'contact_id', 'id');
}
public function getDirection()
{
return ($this->direction) ? "Out" : "In";
}
public function getStatusAttribute($attribute)
{
try{
$v = $this->getStatusOptions()[$attribute];
}
catch(\Throwable $th){
$v = "Error";
}
return $v;
}
public function getStatusOptions()
{
return [
0 => 'default',
1 => 'in process',
2 => 'send',
3 => 'received',
4 => 'connection error',
];
}
public function getRegNumber()
{
return $this->login ?? '';
}
}