mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Full text search fixes - addresses laravel bug :(
This commit is contained in:
parent
9e9a5b7a53
commit
e9c3d6bfb7
|
@ -137,30 +137,61 @@ class AssetsController extends Controller
|
|||
|
||||
|
||||
// This is used by the sidenav, mostly
|
||||
|
||||
// We switched from using query scopes here because of a Laravel bug
|
||||
// related to fulltext searches on complex queries.
|
||||
// I am sad. :(
|
||||
switch ($request->input('status')) {
|
||||
case 'Deleted':
|
||||
$assets->withTrashed()->Deleted();
|
||||
break;
|
||||
case 'Pending':
|
||||
$assets->Pending();
|
||||
$assets->join('status_labels',function ($join) {
|
||||
$join->on('status_labels.id', "=", "assets.status_id")
|
||||
->where('status_labels.deployable','=',0)
|
||||
->where('status_labels.pending','=',1)
|
||||
->where('status_labels.archived', '=', 0);
|
||||
});
|
||||
break;
|
||||
case 'RTD':
|
||||
$assets->RTD();
|
||||
$assets->join('status_labels',function ($join) {
|
||||
$join->on('status_labels.id', "=", "assets.status_id")
|
||||
->where('status_labels.deployable','=',1)
|
||||
->where('status_labels.pending','=',0)
|
||||
->where('status_labels.archived', '=', 0);
|
||||
});
|
||||
break;
|
||||
case 'Undeployable':
|
||||
$assets->Undeployable();
|
||||
break;
|
||||
case 'Archived':
|
||||
$assets->Archived();
|
||||
$assets->join('status_labels',function ($join) {
|
||||
$join->on('status_labels.id', "=", "assets.status_id")
|
||||
->where('status_labels.deployable','=',0)
|
||||
->where('status_labels.pending','=',0)
|
||||
->where('status_labels.archived', '=', 1);
|
||||
});
|
||||
break;
|
||||
case 'Requestable':
|
||||
$assets->RequestableAssets();
|
||||
$assets->where('assets.requestable', '=', 1)
|
||||
->join('status_labels',function ($join) {
|
||||
$join->on('status_labels.id', "=", "assets.status_id")
|
||||
->where('status_labels.deployable','=',1)
|
||||
->where('status_labels.pending','=',0)
|
||||
->where('status_labels.archived', '=', 0);
|
||||
});
|
||||
|
||||
break;
|
||||
case 'Deployed':
|
||||
$assets->Deployed();
|
||||
// more sad, horrible workarounds for laravel bugs when doing full text searches
|
||||
$assets->where('assets.assigned_to', '>', '0');
|
||||
break;
|
||||
default:
|
||||
$assets->NotArchived();
|
||||
// terrible workaround for complex-query Laravel bug in fulltext
|
||||
$assets->join('status_labels',function ($join) {
|
||||
$join->on('status_labels.id', "=", "assets.status_id")
|
||||
->where('status_labels.archived', '=', 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue