31 lines
775 B
PHP
31 lines
775 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class TlsaRecord extends Model
|
|
{
|
|
protected $fillable = [
|
|
'domain_id', 'service', 'host', 'usage', 'selector', 'matching', 'hash', 'cert_path',
|
|
];
|
|
|
|
// Relation zur Domain (FK: domain_id)
|
|
public function domain()
|
|
{
|
|
return $this->belongsTo(Domain::class);
|
|
}
|
|
|
|
public function scopeForServer(Builder $q): Builder
|
|
{
|
|
return $q->whereHas('domain', fn($d) => $d->where('is_server', true));
|
|
}
|
|
|
|
// Fertige Ausgabe-Zeile
|
|
public function getDnsStringAttribute(): string
|
|
{
|
|
return "{$this->service}.{$this->host}. IN TLSA {$this->usage} {$this->selector} {$this->matching} {$this->hash}";
|
|
}
|
|
}
|