hasOneThrough(Account::class,Service::class); } public function registrar() { return $this->belongsTo(DomainRegistrar::class,'domain_registrar_id'); } public function tld() { return $this->belongsTo(DomainTld::class,'domain_tld_id'); } /* SCOPES */ /** * Search for a record * * @param $query * @param string $term * @return mixed */ public function scopeSearch($query,string $term) { // If we have a period in the name, we'll ignore everything after it. $term = strstr($term,'.',TRUE) ?: $term; // Build our where clause return parent::scopeSearch($query,$term) ->orwhere('domain_name','like','%'.$term.'%'); } /* ATTRIBUTES */ public function getServiceDescriptionAttribute(): string { // N/A return 'Domain Name'; } public function getServiceExpireAttribute(): Carbon { return $this->domain_expire; } /** * The name of the domain with its TLD * * @return string */ public function getServiceNameAttribute(): string { return strtoupper(sprintf('%s.%s',$this->domain_name,$this->tld->name)); } public function inContract(): bool { return $this->domain_expire->isFuture(); } }