clrghouz/app/Traits/MsgID.php

25 lines
528 B
PHP

<?php
/**
* Add MsgID to new models
*/
namespace App\Traits;
use Illuminate\Support\Arr;
use App\Classes\FTN\Message;
use App\Models\Setup;
trait MsgID
{
public function save(array $options = [])
{
// Only create a MSGID for locally generated content
if ((! $this->exists) && ($this->flags & Message::FLAG_LOCAL) && (is_null(Arr::get($this->attributes,'msgid')))) {
$ftn = our_address($this->fftn);
$this->attributes['msgid'] = sprintf('%s %08x',$ftn->ftn4d,timew());
}
return parent::save($options);
}
}