Add VOIP to search

This commit is contained in:
Deon George
2021-07-19 16:42:37 +10:00
parent f22813bb5b
commit fa62a47680
3 changed files with 35 additions and 5 deletions

View File

@@ -18,6 +18,25 @@ class Voip extends ServiceType implements ServiceItem
];
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
*
@@ -40,9 +59,11 @@ class Voip extends ServiceType implements ServiceItem
*/
public function getServiceNameAttribute(): string
{
return $this->service_number;
return $this->service_number ?: $this->service_address;
}
/* METHODS */
public function inContract(): bool
{
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();