Initial reseller domain report, enable editing domain service details
This commit is contained in:
@@ -2,23 +2,41 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\DomainRegistrar;
|
||||
use App\Models\DomainTld;
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Traits\NextKey;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\{Account,DomainRegistrar,DomainTld,Service};
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Traits\{NextKey,ScopeServiceActive,ScopeServiceUserAuthorised};
|
||||
|
||||
/**
|
||||
* Class Domain (Service)
|
||||
* Services that domain names
|
||||
*
|
||||
* Attributes for services:
|
||||
* + service_description : Description as shown in a Service Context
|
||||
* + service_expire : The date the service expires
|
||||
* + service_name : Name as shown in a Service Context
|
||||
*
|
||||
* @package App\Models\Service
|
||||
*/
|
||||
class Domain extends ServiceType implements ServiceItem
|
||||
{
|
||||
use NextKey;
|
||||
const RECORD_ID = 'service__domain';
|
||||
use ScopeServiceActive,ScopeServiceUserAuthorised;
|
||||
|
||||
protected $dates = [
|
||||
'domain_expire',
|
||||
];
|
||||
protected $table = 'ab_service__domain';
|
||||
protected $table = 'service_domains';
|
||||
protected $with = ['tld'];
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->hasOneThrough(Account::class,Service::class);
|
||||
}
|
||||
|
||||
public function registrar()
|
||||
{
|
||||
return $this->belongsTo(DomainRegistrar::class,'domain_registrar_id');
|
||||
@@ -29,15 +47,46 @@ class Domain extends ServiceType implements ServiceItem
|
||||
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 sprintf('%s.%s',strtoupper($this->domain_name),strtoupper($this->tld->name));
|
||||
return strtoupper(sprintf('%s.%s',$this->domain_name,$this->tld->name));
|
||||
}
|
||||
|
||||
public function inContract(): bool
|
||||
|
Reference in New Issue
Block a user