From 23f23dfe404f00d08c50b695d55c0a8b5b8a6d58 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 17 Aug 2024 14:39:52 +1000 Subject: [PATCH] Fix showing all traffic usage for broadband --- app/Models/Service/Broadband.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Models/Service/Broadband.php b/app/Models/Service/Broadband.php index 62cfa75..864ee15 100644 --- a/app/Models/Service/Broadband.php +++ b/app/Models/Service/Broadband.php @@ -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