23 lines
675 B
PHP
23 lines
675 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class DmarcRecord extends Model
|
|
{
|
|
protected $fillable = ['domain_id','policy','rua','ruf','pct','record_txt','is_active'];
|
|
protected $casts = ['pct' => 'int','is_active' => 'boolean'];
|
|
|
|
public function domain(): BelongsTo { return $this->belongsTo(Domain::class); }
|
|
|
|
public function renderTxt(): string {
|
|
$parts = ['v=DMARC1', "p={$this->policy}", "pct={$this->pct}"];
|
|
if ($this->rua) $parts[] = "rua={$this->rua}";
|
|
if ($this->ruf) $parts[] = "ruf={$this->ruf}";
|
|
return implode('; ', $parts);
|
|
}
|
|
|
|
}
|