Some message optimisation, added Echomail processing
This commit is contained in:
25
app/Traits/MsgID.php
Normal file
25
app/Traits/MsgID.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add MsgID to new models
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Models\Setup;
|
||||
|
||||
trait MsgID
|
||||
{
|
||||
public function save(array $options = [])
|
||||
{
|
||||
if (! $this->exists) {
|
||||
$ftns = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone);
|
||||
|
||||
if (is_null(Arr::get($this->attributes,'msgid')))
|
||||
$this->attributes['msgid'] = sprintf('%s %08x',$ftns->ftn4d,timew());
|
||||
}
|
||||
|
||||
return parent::save($options);
|
||||
}
|
||||
}
|
33
app/Traits/UseMongo.php
Normal file
33
app/Traits/UseMongo.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Models that store data in Mongo
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
trait UseMongo
|
||||
{
|
||||
/**
|
||||
* Resolve a connection instance.
|
||||
* We need to do this, because our relations are in pgsql and somehow loading a relation changes this models
|
||||
* connection information. Using protected $connection is not enough.
|
||||
*
|
||||
* @param string|null $connection
|
||||
*/
|
||||
public static function resolveConnection($connection = null)
|
||||
{
|
||||
return static::$resolver->connection('mongodb');
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
public function getMsgAttribute($value): string
|
||||
{
|
||||
return utf8_decode($value);
|
||||
}
|
||||
|
||||
public function setMsgAttribute($value): void
|
||||
{
|
||||
$this->attributes['msg'] = utf8_encode($value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user