Fix showing all traffic usage for broadband
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 35s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-08-17 14:39:52 +10:00
parent 7e784c3e81
commit 23f23dfe40

View File

@ -52,9 +52,7 @@ class Broadband extends Type implements ServiceUsage
*/
public function traffic()
{
return $this->hasMany(UsageBroadband::class,'service_item_id')
->where('date','>=',Carbon::now()->startOfMonth());
//->where('site_id',$this->site_id);
return $this->hasMany(UsageBroadband::class,'service_item_id');
}
/* ATTRIBUTES */
@ -144,9 +142,11 @@ class Broadband extends Type implements ServiceUsage
*/
private function usage_last_date(): ?UsageBroadband
{
return $this->traffic
->sortBy('date')
->last();
return $this->traffic()
->orderBy('date','DESC')
->limit(1)
->get()
->first();
}
public function usage_summary(int $months=2): Collection