Move mailer details into a separate table
This commit is contained in:
@@ -48,6 +48,18 @@ class System extends Model
|
||||
->active();
|
||||
}
|
||||
|
||||
public function mailers()
|
||||
{
|
||||
return $this->belongsToMany(Mailer::class)
|
||||
->withPivot(['last_poll','port','attempts','active']);
|
||||
}
|
||||
|
||||
public function mailer_preferred()
|
||||
{
|
||||
return $this->mailers()
|
||||
->preferred();
|
||||
}
|
||||
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(SystemLog::class);
|
||||
@@ -119,11 +131,11 @@ class System extends Model
|
||||
|
||||
public function getAccessMailerAttribute(): string
|
||||
{
|
||||
switch ($this->mailer_type) {
|
||||
case Setup::O_BINKP: return sprintf('binkp://%s:%s',$this->mailer_address,$this->mailer_port);
|
||||
case Setup::O_EMSI: return sprintf('emsi://%s:%s',$this->mailer_address,$this->mailer_port);
|
||||
switch (($x=$this->mailer_preferred()->first())?->name) {
|
||||
case 'BINKP': return sprintf('binkp://%s:%s',$this->address,$x->pivot->port);
|
||||
case 'EMSI': return sprintf('emsi://%s:%s',$this->address,$x->pivot->port);
|
||||
default:
|
||||
return $this->mailer_type ? sprintf('%s:%s',$this->address,$this->port) : 'No mailer available.';
|
||||
return $x?->name ? sprintf('%s:%s',$this->address,$x->pivot->port) : 'No mailer available.';
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user