ADSL Traffic import

This commit is contained in:
Deon George
2020-05-28 15:08:13 +10:00
parent 86861a6daf
commit 7d41fb857a
9 changed files with 341 additions and 3 deletions

View File

@@ -2,9 +2,38 @@
namespace App\Models;
use App\Models\Service\AdslTraffic;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class AdslSupplier extends Model
{
protected $table = 'ab_adsl_supplier';
protected $dates = [
'stats_lastupdate',
];
public $timestamps = FALSE;
/** SCOPES */
/**
* Only query active categories
*/
public function scopeActive($query)
{
return $query->where('active',TRUE);
}
/** METHODS **/
public function traffic_mismatch(Carbon $date): Collection
{
return AdslTraffic::where('date',$date->format('Y-m-d'))
->where('supplier_id',$this->id)
->whereNULL('ab_service_adsl_id')
->get();
}
}

View File

@@ -21,6 +21,18 @@ class Adsl extends ServiceType implements ServiceItem
];
protected $table = 'ab_service__adsl';
/** RELATIONSHIPS **/
/**
* The accounts that this user manages
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function traffic()
{
return $this->hasMany(AdslTraffic::class,'ab_service_adsl_id');
}
/** SCOPES */
/**

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models\Service;
use Illuminate\Database\Eloquent\Model;
class AdslTraffic extends Model
{
protected $table = 'ab_service__adsl_traffic';
public $timestamps = FALSE;
public function broadband()
{
return $this->belongsTo(Adsl::class);
}
}