2018-06-19 12:31:49 +00:00
|
|
|
<?php
|
|
|
|
|
2019-06-07 06:54:27 +00:00
|
|
|
namespace App\Models\Service;
|
2018-06-19 12:31:49 +00:00
|
|
|
|
2020-02-08 11:51:50 +00:00
|
|
|
use App\Interfaces\ServiceItem;
|
|
|
|
use App\Models\Base\ServiceType;
|
2019-06-13 04:32:34 +00:00
|
|
|
use App\Traits\NextKey;
|
2021-07-13 02:31:56 +00:00
|
|
|
use Carbon\Carbon;
|
2019-06-13 04:32:34 +00:00
|
|
|
|
2020-02-08 11:51:50 +00:00
|
|
|
class Voip extends ServiceType implements ServiceItem
|
2018-06-19 12:31:49 +00:00
|
|
|
{
|
2019-06-13 04:32:34 +00:00
|
|
|
use NextKey;
|
|
|
|
const RECORD_ID = 'service__adsl';
|
|
|
|
|
2020-02-19 12:37:45 +00:00
|
|
|
protected $dates = [
|
|
|
|
'service_connect_date',
|
|
|
|
'service_contract_date',
|
|
|
|
];
|
2022-04-02 07:06:34 +00:00
|
|
|
public $dateFormat = 'U';
|
2018-06-19 12:31:49 +00:00
|
|
|
protected $table = 'ab_service__voip';
|
|
|
|
|
2021-07-19 06:42:37 +00:00
|
|
|
/* SCOPES */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search for a record
|
|
|
|
*
|
|
|
|
* @param $query
|
|
|
|
* @param string $term
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public function scopeSearch($query,string $term)
|
|
|
|
{
|
|
|
|
// Build our where clause
|
|
|
|
return parent::scopeSearch($query,$term)
|
|
|
|
->orwhere('service_number','like','%'.$term.'%')
|
|
|
|
->orWhere('service_address','like','%'.$term.'%');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ATTRIBUTES */
|
|
|
|
|
2020-02-08 11:51:50 +00:00
|
|
|
/**
|
|
|
|
* Return the service address
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getServiceDescriptionAttribute(): string
|
2018-11-21 03:37:17 +00:00
|
|
|
{
|
2020-02-08 11:51:50 +00:00
|
|
|
return $this->service_address ?: 'VOIP';
|
2018-11-21 03:37:17 +00:00
|
|
|
}
|
|
|
|
|
2021-07-13 02:31:56 +00:00
|
|
|
public function getServiceExpireAttribute(): Carbon
|
|
|
|
{
|
|
|
|
// TODO: Implement getServiceExpireAttribute() method.
|
|
|
|
}
|
|
|
|
|
2020-02-08 11:51:50 +00:00
|
|
|
/**
|
|
|
|
* Return the service number
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getServiceNameAttribute(): string
|
2018-06-19 12:31:49 +00:00
|
|
|
{
|
2021-12-14 02:14:14 +00:00
|
|
|
return $this->service_number ?: ($this->service_address ?: 'Unknown');
|
2018-06-19 12:31:49 +00:00
|
|
|
}
|
2020-02-19 12:37:45 +00:00
|
|
|
|
2021-07-19 06:42:37 +00:00
|
|
|
/* METHODS */
|
|
|
|
|
2020-02-19 12:37:45 +00:00
|
|
|
public function inContract(): bool
|
|
|
|
{
|
|
|
|
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
|
|
|
|
}
|
2018-06-19 12:31:49 +00:00
|
|
|
}
|