Work on SSL and Host accounts

This commit is contained in:
Deon George
2020-02-20 22:54:28 +11:00
parent 8311bfc268
commit 9ab30086fc
17 changed files with 225 additions and 20 deletions

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DomainRegistrar extends Model
{
protected $table = 'ab_domain_registrar';
}

10
app/Models/HostServer.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class HostServer extends Model
{
protected $table = 'ab_host_server';
}

View File

@@ -151,4 +151,9 @@ class Adsl extends ProductType implements ProductSupplier
// @todo Tax shouldnt be hard coded
return ($this->product->base_cost+$this->allowance_cost())*1.1;
}
public function getSupplierAttribute()
{
return $this->getRelationValue('supplier');
}
}

View File

@@ -30,4 +30,9 @@ class Domain extends ProductType implements ProductSupplier
// N/A
return 0;
}
public function getSupplierAttribute()
{
return '';
}
}

View File

@@ -2,11 +2,11 @@
namespace App\Models\Product;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
class Host extends \App\Models\Base\ProductType
class Host extends ProductType
{
use NextKey;
const RECORD_ID = '';
}

View File

@@ -32,4 +32,23 @@ class SSL extends ProductType implements ProductSupplier
// N/A
return 0;
}
public function getProductAttribute()
{
$o = new \stdClass();
$o->product_id = 'INT';
$o->setup_cost = 0;
$o->base_cost = 0;
$o->contract_term = 0; // @todo
return $o;
}
public function getSupplierAttribute()
{
$o = new \stdClass();
$o->name = 'Internal';
return $o;
}
}

View File

@@ -2,11 +2,11 @@
namespace App\Models\Product;
use App\Models\Base\ProductType;
use App\Traits\NextKey;
class Voip extends \App\Models\Base\ProductType
class Voip extends ProductType
{
use NextKey;
const RECORD_ID = '';
}

View File

@@ -819,7 +819,7 @@ class Service extends Model
}
// If the service is active, there will be service charges
if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->sum('total'))
if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->count())
AND ($this->active OR $this->isPending()))
{
do {

View File

@@ -32,7 +32,7 @@ class Domain extends ServiceType implements ServiceItem
public function getServiceDescriptionAttribute(): string
{
// N/A
return '';
return 'Domain Name';
}
public function getServiceNameAttribute(): string

View File

@@ -2,17 +2,45 @@
namespace App\Models\Service;
use App\Interfaces\ServiceItem;
use App\Models\Base\ServiceType;
use App\Models\DomainTld;
use App\Models\HostServer;
use App\Traits\NextKey;
class Host extends \App\Models\Base\ServiceType
class Host extends ServiceType implements ServiceItem
{
use NextKey;
const RECORD_ID = 'service__hosting';
protected $dates = [
'host_expire',
];
protected $table = 'ab_service__hosting';
public function getNameAttribute()
public function provider()
{
return sprintf('%s',$this->domain_name);
return $this->belongsTo(HostServer::class,'host_server_id');
}
public function tld()
{
return $this->belongsTo(DomainTld::class,'domain_tld_id');
}
public function getServiceDescriptionAttribute(): string
{
// N/A
return 'Hosting';
}
public function getServiceNameAttribute(): string
{
return sprintf('%s.%s',strtoupper($this->domain_name),strtoupper($this->tld->name));
}
public function inContract(): bool
{
return $this->host_expire->isFuture();
}
}

View File

@@ -2,9 +2,11 @@
namespace App\Models\Service;
use App\Interfaces\ServiceItem;
use App\Models\Base\ServiceType;
use App\Traits\NextKey;
class SSL extends \App\Models\Base\ServiceType
class SSL extends ServiceType implements ServiceItem
{
use NextKey;
const RECORD_ID = 'service__ssl';
@@ -13,15 +15,9 @@ class SSL extends \App\Models\Base\ServiceType
protected $_o = NULL;
public function tld()
{
return $this->belongsTo(DomainTld::class,'domain_tld_id');
}
public function getSSLAttribute()
{
if (is_null($this->_o))
{
if (is_null($this->_o)) {
$this->_o = new \App\Classes\SSL;
if ($this->cert)
@@ -30,14 +26,24 @@ class SSL extends \App\Models\Base\ServiceType
$this->_o->csr($this->csr);
if ($this->pk)
$this->_o->key($this->pk);
}
return $this->_o;
}
public function getNameAttribute()
public function getServiceDescriptionAttribute(): string
{
return $this->ssl->dn;
}
public function getServiceNameAttribute(): string
{
return $this->ssl->cn;
}
public function inContract(): bool
{
// N/A
return FALSE;
}
}