osb/app/Models/Service/Adsl.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2018-05-20 12:53:14 +00:00
<?php
namespace App\Models\Service;
2018-05-20 12:53:14 +00:00
use App\Traits\NextKey;
class Adsl extends \App\Models\Base\ServiceType
2018-05-20 12:53:14 +00:00
{
use NextKey;
const RECORD_ID = 'service__adsl';
// @todo column service_id can be removed.
2018-05-20 12:53:14 +00:00
protected $table = 'ab_service__adsl';
2019-06-29 00:14:12 +00:00
protected $dates = ['service_connect_date','service_contract_date'];
2018-05-20 12:53:14 +00:00
2019-06-29 00:14:12 +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.'%')
->orWhere('ipaddress','like','%'.$term.'%');
}
/** ATTRIBUTES **/
/**
* @deprecated use getNameFullAttribute()
*/
2018-11-21 03:37:17 +00:00
public function getFullNameAttribute()
{
2019-06-29 00:14:12 +00:00
return $this->getNameFullAttribute();
2018-11-21 03:37:17 +00:00
}
2018-05-20 12:53:14 +00:00
public function getNameAttribute()
{
2018-08-11 05:09:41 +00:00
return $this->service_number ?: $this->service_address;
2018-05-20 12:53:14 +00:00
}
2019-06-29 00:14:12 +00:00
public function getNameFullAttribute()
{
return ($this->service_number AND $this->service_address)
? sprintf('%s: %s',$this->service_number, $this->service_address)
: $this->name;
}
2018-05-20 12:53:14 +00:00
}