Work on products, first completed broadband

This commit is contained in:
Deon George
2021-12-24 12:14:01 +11:00
parent 8f5293662e
commit 1e9f15b40f
62 changed files with 2139 additions and 894 deletions

View File

@@ -3,17 +3,15 @@
namespace App\Models\Service;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Leenooks\Carbon;
use App\Interfaces\{ServiceItem,ServiceUsage};
use App\Models\AdslSupplierPlan;
use App\Models\Base\ServiceType;
use App\Models\Supplier\Broadband as SupplierBroadband;
use App\Traits\NextKey;
class Adsl extends ServiceType implements ServiceItem,ServiceUsage
class Broadband extends ServiceType implements ServiceItem,ServiceUsage
{
private const LOGKEY = 'MSA';
@@ -26,21 +24,7 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
];
protected $table = 'ab_service__adsl';
/** RELATIONSHIPS **/
/**
* The suppliers product
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function product()
{
return $this
->hasOne(AdslSupplierPlan::class,'id','adsl_supplier_plan_id')
->withDefault(function() {
$o = new AdslSupplierPlan;
});
}
/* RELATIONS */
/**
* The accounts that this user manages
@@ -53,7 +37,7 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
return $this->hasMany(AdslTraffic::class,'ab_service_adsl_id');
}
/** SCOPES */
/* SCOPES */
/**
* Search for a record
@@ -71,12 +55,13 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
->orWhere('ipaddress','like','%'.$term.'%');
}
/** ATTRIBUTES **/
/**
* @deprecated use $o->service_name;
* @return mixed|string
*/
/* ATTRIBUTES */
public function getNameAttribute()
{
return $this->service_number ?: $this->service_address;
@@ -107,6 +92,8 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
return $this->service_number ?: $this->service_address;
}
/* METHODS */
/**
* Is this service currently in a contract
*
@@ -117,6 +104,18 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
}
/**
* Return the suppliers offering that this service is providing
*
* @return SupplierBroadband
*/
public function supplied(): SupplierBroadband
{
return $this->provided_adsl_plan_id
? SupplierBroadband::findOrFail($this->provided_adsl_plan_id)
: $this->service->product->type->supplied;
}
/**
* Return service usage data
*

View File

@@ -67,7 +67,7 @@ class SSL extends ServiceType implements ServiceItem
{
return $this->cert
? Arr::get($this->crt_parse,'subject.CN')
: Arr::get(openssl_csr_get_subject($this->csr),'CN');
: Arr::get(openssl_csr_get_subject($this->csr),'CN','');
}
public function inContract(): bool