2021-07-30 14:35:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add MsgID to new models
|
|
|
|
*/
|
|
|
|
namespace App\Traits;
|
|
|
|
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
2022-01-01 05:59:35 +00:00
|
|
|
use App\Classes\FTN\Message;
|
2021-07-30 14:35:52 +00:00
|
|
|
use App\Models\Setup;
|
|
|
|
|
|
|
|
trait MsgID
|
|
|
|
{
|
|
|
|
public function save(array $options = [])
|
|
|
|
{
|
2022-01-22 12:08:46 +00:00
|
|
|
// Only create a MSGID for locally generated content
|
2022-01-01 05:59:35 +00:00
|
|
|
if ((! $this->exists) && ($this->flags & Message::FLAG_LOCAL)) {
|
2021-08-08 13:53:56 +00:00
|
|
|
$ftns = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first();
|
2021-07-30 14:35:52 +00:00
|
|
|
|
|
|
|
if (is_null(Arr::get($this->attributes,'msgid')))
|
|
|
|
$this->attributes['msgid'] = sprintf('%s %08x',$ftns->ftn4d,timew());
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::save($options);
|
|
|
|
}
|
|
|
|
}
|