48 lines
906 B
PHP
48 lines
906 B
PHP
<?php
|
|
|
|
namespace App\Models\Supplier;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use App\Models\Product\Domain as ProductDomain;
|
|
use App\Models\TLD;
|
|
|
|
final class Domain extends Type
|
|
{
|
|
protected const category_name = 'Domain';
|
|
|
|
protected $table = 'supplier_domain';
|
|
|
|
// The model of the product that is supplied by this model
|
|
const ProductModel = ProductDomain::class;
|
|
|
|
/* INTERFACES */
|
|
|
|
public function getNameAttribute(): string
|
|
{
|
|
return sprintf('%s: %s',$this->product_id,$this->tld->name);
|
|
}
|
|
|
|
/* STATIC */
|
|
|
|
/**
|
|
* Determine the owner of the name servers used for the domain
|
|
*
|
|
*/
|
|
public static function nameserver_name(Collection $nameservers): string
|
|
{
|
|
foreach (config('nameservers') as $key => $ns) {
|
|
if ($nameservers->diff($ns)->count() < count($ns))
|
|
return $key;
|
|
}
|
|
|
|
return 'custom';
|
|
}
|
|
|
|
/* RELATIONS */
|
|
|
|
public function tld()
|
|
{
|
|
return $this->belongsTo(TLD::class);
|
|
}
|
|
} |