Update and fix broadband traffic
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Interfaces\ServiceUsage;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\Supplier\Broadband as SupplierBroadband;
|
||||
use App\Models\Supplier\Type;
|
||||
use App\Models\Usage\Broadband as UsageBroadband;
|
||||
|
||||
/**
|
||||
* Class Broadband (Service)
|
||||
@@ -65,17 +66,15 @@ class Broadband extends ServiceType implements ServiceUsage
|
||||
return $this->service_number ?: ($this->service_address ?: '-');
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
* The accounts that this user manages
|
||||
* The usage information for broadband
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function traffic()
|
||||
{
|
||||
// @todo Need to include site_id in this relation
|
||||
return $this->hasMany(AdslTraffic::class,'ab_service_adsl_id');
|
||||
return $this->hasMany(UsageBroadband::class,'service_item_id')
|
||||
->where('site_id',$this->site_id);
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
@@ -128,8 +127,6 @@ class Broadband extends ServiceType implements ServiceUsage
|
||||
if (! $maxdate)
|
||||
return collect();
|
||||
|
||||
Log::debug(sprintf('%s:Getting Usage data for [%d] days from [%s]',self::LOGKEY,$days,$maxdate->date->format('Y-m-d')),['m'=>__METHOD__]);
|
||||
|
||||
return $this->traffic()
|
||||
->where('date','<=',$maxdate->date->format('Y-m-d'))
|
||||
->where('date','>=',$maxdate->date->subDays($days)->format('Y-m-d'))
|
||||
@@ -139,9 +136,9 @@ class Broadband extends ServiceType implements ServiceUsage
|
||||
/**
|
||||
* Find the last date any traffic was recorded for a service
|
||||
*
|
||||
* @return AdslTraffic|null
|
||||
* @return UsageBroadband|null
|
||||
*/
|
||||
private function usage_last_date(): ?AdslTraffic
|
||||
private function usage_last_date(): ?UsageBroadband
|
||||
{
|
||||
return $this->traffic
|
||||
->sortBy('date')
|
||||
|
Reference in New Issue
Block a user