osb/app/Models/Service/Voip.php

71 lines
1.4 KiB
PHP

<?php
namespace App\Models\Service;
use App\Interfaces\ServiceItem;
use App\Models\Base\ServiceType;
use App\Traits\NextKey;
use Carbon\Carbon;
class Voip extends ServiceType implements ServiceItem
{
use NextKey;
const RECORD_ID = 'service__adsl';
protected $dates = [
'service_connect_date',
'service_contract_date',
];
protected $table = 'ab_service__voip';
/* 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 */
/**
* Return the service address
*
* @return string
*/
public function getServiceDescriptionAttribute(): string
{
return $this->service_address ?: 'VOIP';
}
public function getServiceExpireAttribute(): Carbon
{
// TODO: Implement getServiceExpireAttribute() method.
}
/**
* Return the service number
*
* @return string
*/
public function getServiceNameAttribute(): string
{
return $this->service_number ?: ($this->service_address ?: 'Unknown');
}
/* METHODS */
public function inContract(): bool
{
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
}
}