osb/app/Models/Product/Adsl.php

36 lines
754 B
PHP
Raw Normal View History

2019-07-02 05:28:27 +00:00
<?php
namespace App\Models\Product;
use App\Traits\NextKey;
use App\Models\AdslSupplierPlan;
class Adsl extends \App\Models\Base\ProductType
{
use NextKey;
const RECORD_ID = 'adsl_plan';
protected $table = 'ab_adsl_plan';
public function product()
{
return $this->hasOne(AdslSupplierPlan::class,'id','adsl_supplier_plan_id');
}
public function __get($key)
{
switch($key)
{
case 'base_down_peak':
return $this->attributes['base_down_peak']/$this->attributes['metric'];
case 'base_down_peak':
return $this->attributes['base_down_offpeak']/$this->attributes['metric'];
case 'speed':
return $this->product->speed;
}
// If we dont have a specific key, we'll resolve it normally
return parent::__get($key);
}
}