Improved search performance
This commit is contained in:
@@ -32,6 +32,8 @@ class HomeController extends Controller
|
||||
if (! $o->exists)
|
||||
$o = Auth::user();
|
||||
|
||||
$o->load(['services.invoice_items','services.type']);
|
||||
|
||||
return View('u.home',['o'=>$o]);
|
||||
}
|
||||
|
||||
|
@@ -51,9 +51,9 @@ class SearchController extends Controller
|
||||
foreach (Service::Search($request->input('term'))
|
||||
->whereIN('account_id',$account_ids)
|
||||
->orderBy('id')
|
||||
->limit(10)->get() as $o)
|
||||
->limit(20)->get() as $o)
|
||||
{
|
||||
$result->push(['name'=>sprintf('%s (%s)',$o->name,$o->lid),'value'=>'/u/service/'.$o->id,'category'=>'Services']);
|
||||
$result->push(['name'=>sprintf('%s (%s) %s',$o->name,$o->lid,$o->active ? '' : '<small>INACT</small>'),'value'=>'/u/service/'.$o->id,'category'=>$o->category_name]);
|
||||
}
|
||||
|
||||
# Look for an Invoice
|
||||
@@ -65,36 +65,6 @@ class SearchController extends Controller
|
||||
$result->push(['name'=>sprintf('%s: %s',$o->lid,$o->account->name),'value'=>'/u/invoice/'.$o->id,'category'=>'Invoices']);
|
||||
}
|
||||
|
||||
# Look for a Broadband Service
|
||||
foreach (Broadband::Search($request->input('term'))
|
||||
->whereIN('account_id',$account_ids)
|
||||
->orderBy('service_number')
|
||||
->with(['service'])
|
||||
->limit(10)->get() as $o)
|
||||
{
|
||||
$result->push(['name'=>sprintf('%s (%s)',$o->service->name,$o->service->lid),'value'=>'/u/service/'.$o->service_id,'category'=>'Broadband']);
|
||||
}
|
||||
|
||||
# Look for a Phone Service
|
||||
foreach (Phone::Search($request->input('term'))
|
||||
->whereIN('account_id',$account_ids)
|
||||
->orderBy('service_number')
|
||||
->with(['service'])
|
||||
->limit(10)->get() as $o)
|
||||
{
|
||||
$result->push(['name'=>sprintf('%s (%s)',$o->service->name,$o->service->lid),'value'=>'/u/service/'.$o->service_id,'category'=>'Phone']);
|
||||
}
|
||||
|
||||
# Look for Domain Name
|
||||
foreach (Service\Domain::Search($request->input('term'))
|
||||
->whereIN('account_id',$account_ids)
|
||||
->orderBy('domain_name')
|
||||
->with(['service'])
|
||||
->limit(10)->get() as $o)
|
||||
{
|
||||
$result->push(['name'=>sprintf('%s (%s)',$o->service->name,$o->service->lid),'value'=>'/u/service/'.$o->service_id,'category'=>'Domains']);
|
||||
}
|
||||
|
||||
if (Gate::any(['wholesaler'],new Payment)) {
|
||||
# Look for Payments
|
||||
foreach (Payment::Search($request->input('term'))
|
||||
@@ -105,6 +75,6 @@ class SearchController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $result->sortBy(function($item) { return $item['category'].$item['name']; })->values();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user