osb/app/Models/Service/Adsl.php
2019-06-29 10:14:12 +10:00

56 lines
1.1 KiB
PHP

<?php
namespace App\Models\Service;
use App\Traits\NextKey;
class Adsl extends \App\Models\Base\ServiceType
{
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'];
/** 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.'%')
->orWhere('ipaddress','like','%'.$term.'%');
}
/** ATTRIBUTES **/
/**
* @deprecated use getNameFullAttribute()
*/
public function getFullNameAttribute()
{
return $this->getNameFullAttribute();
}
public function getNameAttribute()
{
return $this->service_number ?: $this->service_address;
}
public function getNameFullAttribute()
{
return ($this->service_number AND $this->service_address)
? sprintf('%s: %s',$this->service_number, $this->service_address)
: $this->name;
}
}