Work on Service rendering
This commit is contained in:
@@ -2,17 +2,35 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Models\Service;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Adsl extends \App\Models\Base\ServiceType
|
||||
class Adsl extends ServiceType implements ServiceItem
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__adsl';
|
||||
|
||||
// @todo column service_id can be removed.
|
||||
protected $table = 'ab_service__adsl';
|
||||
protected $dates = ['service_connect_date','service_contract_date'];
|
||||
protected $dates = [
|
||||
'service_connect_date',
|
||||
'service_contract_date'
|
||||
];
|
||||
|
||||
/**
|
||||
* The service this belongs to
|
||||
*
|
||||
* @return BelongsTo|MorphOne
|
||||
*/
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
/** SCOPES */
|
||||
|
||||
@@ -35,22 +53,41 @@ class Adsl extends \App\Models\Base\ServiceType
|
||||
/** ATTRIBUTES **/
|
||||
|
||||
/**
|
||||
* @deprecated use getNameFullAttribute()
|
||||
* @deprecated use $o->type()->service_name;
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->getNameFullAttribute();
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->service_number ?: $this->service_address;
|
||||
}
|
||||
|
||||
public function getNameFullAttribute()
|
||||
/**
|
||||
* Return the service address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
return ($this->service_number AND $this->service_address)
|
||||
? sprintf('%s: %s',$this->service_number, $this->service_address)
|
||||
: $this->name;
|
||||
return $this->service_address ?: 'NO Service Address';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the service number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return $this->service_number ?: 'NO Service Number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this service currently in a contract
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inContract(): bool
|
||||
{
|
||||
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user