Add VOIP to search
This commit is contained in:
parent
f22813bb5b
commit
fa62a47680
@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
use App\Models\{Account,Invoice,Service,Service\Adsl,User};
|
use App\Models\{Account,Invoice,Service,Service\Adsl,Service\Voip,User};
|
||||||
|
|
||||||
class SearchController extends Controller
|
class SearchController extends Controller
|
||||||
{
|
{
|
||||||
@ -69,7 +69,16 @@ class SearchController extends Controller
|
|||||||
->orderBy('service_number')
|
->orderBy('service_number')
|
||||||
->limit(10)->get() as $o)
|
->limit(10)->get() as $o)
|
||||||
{
|
{
|
||||||
$result->push(['name'=>sprintf('%s (%s)',$o->name,$o->service->sid),'value'=>'/u/service/'.$o->id,'category'=>'Broadband']);
|
$result->push(['name'=>sprintf('%s (%s)',$o->service_name,$o->service->sid),'value'=>'/u/service/'.$o->id,'category'=>'Broadband']);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Look for an VOIP Service
|
||||||
|
foreach (Voip::Search($request->input('term'))
|
||||||
|
->whereIN('account_id',$accounts)
|
||||||
|
->orderBy('service_number')
|
||||||
|
->limit(10)->get() as $o)
|
||||||
|
{
|
||||||
|
$result->push(['name'=>sprintf('%s (%s)',$o->service_name,$o->service->sid),'value'=>'/u/service/'.$o->id,'category'=>'VOIP']);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Look for Domain Name
|
# Look for Domain Name
|
||||||
|
@ -74,7 +74,7 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
|
|||||||
/** ATTRIBUTES **/
|
/** ATTRIBUTES **/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use $o->type()->service_name;
|
* @deprecated use $o->service_name;
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
*/
|
*/
|
||||||
public function getNameAttribute()
|
public function getNameAttribute()
|
||||||
@ -104,7 +104,7 @@ class Adsl extends ServiceType implements ServiceItem,ServiceUsage
|
|||||||
*/
|
*/
|
||||||
public function getServiceNameAttribute(): string
|
public function getServiceNameAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->service_number ?: 'NO Service Number';
|
return $this->service_number ?: $this->service_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,25 @@ class Voip extends ServiceType implements ServiceItem
|
|||||||
];
|
];
|
||||||
protected $table = 'ab_service__voip';
|
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 the service address
|
||||||
*
|
*
|
||||||
@ -40,9 +59,11 @@ class Voip extends ServiceType implements ServiceItem
|
|||||||
*/
|
*/
|
||||||
public function getServiceNameAttribute(): string
|
public function getServiceNameAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->service_number;
|
return $this->service_number ?: $this->service_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* METHODS */
|
||||||
|
|
||||||
public function inContract(): bool
|
public function inContract(): bool
|
||||||
{
|
{
|
||||||
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
|
return $this->service_contract_date AND $this->service_contract_date->addMonths($this->contract_term)->isFuture();
|
||||||
|
Loading…
Reference in New Issue
Block a user