Update and fix broadband traffic

This commit is contained in:
Deon George
2022-04-20 16:24:58 +10:00
parent 621a132e35
commit 16b7e0b493
13 changed files with 161 additions and 112 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
@@ -62,7 +63,8 @@ class Supplier extends Model
// EG: Crazy Domains, "domains" and "hosting".
public function detail()
{
return $this->hasOne(SupplierDetail::class);
return $this->hasOne(SupplierDetail::class)
->withoutGlobalScope(\App\Models\Scopes\SiteScope::class);
}
/* METHODS */
@@ -103,4 +105,18 @@ class Supplier extends Model
return $result;
}
/**
* Return the traffic records, that were not matched to a service.
*
* @param Carbon $date
* @return \Illuminate\Database\Eloquent\Collection
*/
public function trafficMismatch(Carbon $date): Collection
{
return Usage\Broadband::where('date',$date->format('Y-m-d'))
->where('supplier_id',$this->id)
->whereNULL('service_item_id')
->get();
}
}