Start work on updating services
This commit is contained in:
@@ -6,24 +6,64 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Leenooks\Carbon;
|
||||
|
||||
use App\Interfaces\{ServiceItem,ServiceUsage};
|
||||
use App\Interfaces\ServiceUsage;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\Supplier\Broadband as SupplierBroadband;
|
||||
use App\Traits\NextKey;
|
||||
use App\Models\Supplier\Type;
|
||||
|
||||
class Broadband extends ServiceType implements ServiceItem,ServiceUsage
|
||||
/**
|
||||
* Class Broadband (Service)
|
||||
* Services that are Internet Broadband
|
||||
*/
|
||||
class Broadband extends ServiceType implements ServiceUsage
|
||||
{
|
||||
private const LOGKEY = 'MSA';
|
||||
|
||||
use NextKey;
|
||||
const RECORD_ID = 'service__adsl';
|
||||
private const LOGKEY = 'MSB';
|
||||
|
||||
protected $dates = [
|
||||
'service_connect_date',
|
||||
'service_contract_date'
|
||||
'connect_at',
|
||||
'expire_at',
|
||||
];
|
||||
public $dateFormat = 'U';
|
||||
protected $table = 'ab_service__adsl';
|
||||
protected $table = 'service_broadband';
|
||||
|
||||
/* ABSTRACT */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeSearch($query,string $term)
|
||||
{
|
||||
// Build our where clause
|
||||
return parent::scopeSearch($query,$term)
|
||||
->orwhere('service_number','like','%'.$term.'%')
|
||||
->orWhere('service_address','like','%'.$term.'%')
|
||||
->orWhere('ipaddress','like','%'.$term.'%');
|
||||
}
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
* Return the service address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
return strtoupper($this->service_address) ?: '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the service number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return $this->service_number ?: ($this->service_address ?: '-');
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
@@ -38,79 +78,37 @@ class Broadband extends ServiceType implements ServiceItem,ServiceUsage
|
||||
return $this->hasMany(AdslTraffic::class,'ab_service_adsl_id');
|
||||
}
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return
|
||||
*/
|
||||
public function scopeSearch($query,string $term)
|
||||
{
|
||||
// Build our where clause
|
||||
return parent::scopeSearch($query,$term)
|
||||
->orwhere('service_number','like','%'.$term.'%')
|
||||
->orWhere('service_address','like','%'.$term.'%')
|
||||
->orWhere('ipaddress','like','%'.$term.'%');
|
||||
}
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* @deprecated use $o->service_name;
|
||||
* @return mixed|string
|
||||
*/
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
abort(500,'deprecated - use $o->service_name');
|
||||
return $this->service_number ?: $this->service_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the service address
|
||||
* The type of technology used to provide this Internet Service
|
||||
*
|
||||
* @return string
|
||||
* @param $value
|
||||
* @return null|string
|
||||
*/
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
public function getTechnologyAttribute($value): ?string
|
||||
{
|
||||
return strtoupper($this->service_address) ?: 'NO Service Address';
|
||||
}
|
||||
|
||||
public function getServiceExpireAttribute(): \Carbon\Carbon
|
||||
{
|
||||
// TODO: Implement getServiceExpireAttribute() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the service number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return $this->service_number ?: $this->service_address;
|
||||
return $value ?: $this->supplied()->technology;
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
* Is this service currently in a contract
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inContract(): bool
|
||||
{
|
||||
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
|
||||
* @return Type
|
||||
*/
|
||||
public function supplied(): SupplierBroadband
|
||||
public function supplied(): Type
|
||||
{
|
||||
return $this->provided_adsl_plan_id
|
||||
? SupplierBroadband::findOrFail($this->provided_adsl_plan_id)
|
||||
@@ -184,4 +182,4 @@ class Broadband extends ServiceType implements ServiceItem,ServiceUsage
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user