Improved search performance
This commit is contained in:
@@ -25,24 +25,6 @@ class Broadband extends Type implements ServiceUsage
|
||||
];
|
||||
protected $table = 'service_broadband';
|
||||
|
||||
/* ABSTRACT */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return mixed
|
||||
*/
|
||||
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.'%');
|
||||
}
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ namespace App\Models\Service;
|
||||
// @todo Document how this is used.
|
||||
class Generic extends Type
|
||||
{
|
||||
protected $table = 'service__generic';
|
||||
protected $table = 'service_generic';
|
||||
public $timestamps = FALSE;
|
||||
|
||||
/* INTERFACE */
|
||||
|
@@ -14,23 +14,6 @@ class Phone extends Type
|
||||
];
|
||||
protected $table = 'service_phone';
|
||||
|
||||
/* ABSTRACT */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return mixed
|
||||
*/
|
||||
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.'%');
|
||||
}
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
|
@@ -33,20 +33,6 @@ class SSL extends Type
|
||||
});
|
||||
}
|
||||
|
||||
/* ABSTRACT */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeSearch($query,string $term)
|
||||
{
|
||||
// @todo
|
||||
}
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
|
@@ -39,23 +39,6 @@ abstract class Type extends Model implements ServiceItem
|
||||
return $this->morphOne(Service::class,'type','model','id','service_id');
|
||||
}
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
*
|
||||
* @param $query
|
||||
* @param string $term
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeSearch($query,string $term)
|
||||
{
|
||||
return $query
|
||||
->with(['service'])
|
||||
->join('services','services.id','=',$this->getTable().'.service_id')
|
||||
->Where('services.id','like','%'.$term.'%');
|
||||
}
|
||||
|
||||
/* INTERFACE */
|
||||
|
||||
public function getContractTermAttribute(): int
|
||||
|
Reference in New Issue
Block a user