Added in email hosting, and other misc cosmetic fixes

This commit is contained in:
Deon George
2022-04-02 18:06:34 +11:00
parent 7775105da6
commit a4ed29b560
35 changed files with 1181 additions and 104 deletions

View File

@@ -10,6 +10,7 @@ class AdslTraffic extends Model
protected $table = 'ab_service__adsl_traffic';
public $timestamps = FALSE;
protected $dates = ['date'];
public $dateFormat = 'U';
private $traffic_end = 14;
public function broadband()

View File

@@ -22,6 +22,7 @@ class Broadband extends ServiceType implements ServiceItem,ServiceUsage
'service_connect_date',
'service_contract_date'
];
public $dateFormat = 'U';
protected $table = 'ab_service__adsl';
/* RELATIONS */

View File

@@ -27,46 +27,11 @@ class Domain extends ServiceType implements ServiceItem
protected $dates = [
'domain_expire',
];
public $dateFormat = 'U';
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');
}
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 */
/* INTERFACES */
public function getServiceDescriptionAttribute(): string
{
@@ -93,4 +58,41 @@ class Domain extends ServiceType implements ServiceItem
{
return $this->domain_expire->isFuture();
}
/* RELATIONS */
public function account()
{
return $this->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 */
}

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Models\Service;
use Carbon\Carbon;
use App\Models\Base\ServiceType;
use App\Models\{Account, DomainRegistrar, DomainTld, Service, TLD};
use App\Interfaces\ServiceItem;
use App\Traits\{NextKey,ScopeServiceActive,ScopeServiceUserAuthorised};
/**
* Class Email (Service)
* Services that email hostings
*
* 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 Email extends ServiceType implements ServiceItem
{
use ScopeServiceActive,ScopeServiceUserAuthorised;
protected $dates = ['expire_at'];
protected $table = 'service_emails';
/* INTERFACES */
public function getServiceDescriptionAttribute(): string
{
// N/A
return 'Email Hosting';
}
public function getServiceExpireAttribute(): Carbon
{
return $this->expire_at ?: $this->service->next_invoice;
}
/**
* The name of the domain with its TLD
*
* @return string
* // @todo
*/
public function getServiceNameAttribute(): string
{
return strtoupper(sprintf('%s.%s',$this->domain_name,$this->tld->name));
}
public function inContract(): bool
{
return $this->expire_at && $this->expire_at->isFuture();
}
/* RELATIONS */
public function tld()
{
return $this->belongsTo(TLD::class);
}
}

View File

@@ -17,6 +17,7 @@ class Host extends ServiceType implements ServiceItem
protected $dates = [
'host_expire',
];
public $dateFormat = 'U';
protected $table = 'ab_service__hosting';
public function provider()

View File

@@ -16,6 +16,7 @@ class Voip extends ServiceType implements ServiceItem
'service_connect_date',
'service_contract_date',
];
public $dateFormat = 'U';
protected $table = 'ab_service__voip';
/* SCOPES */