clrghouz/app/Traits/MsgID.php

27 lines
642 B
PHP
Raw Normal View History

<?php
/**
* Add MsgID to new models
*/
namespace App\Traits;
use Illuminate\Support\Arr;
2024-06-26 06:49:29 +00:00
use Illuminate\Support\Facades\Log;
2022-01-01 05:59:35 +00:00
use App\Classes\FTN\Message;
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());
2024-06-26 06:49:29 +00:00
Log::debug(sprintf('%s:- Auto setting msgid to [%s]',self::LOGKEY,$this->attributes['msgid']));
}
return parent::save($options);
}
}