Full text search fixes - addresses laravel bug :(

This commit is contained in:
snipe 2017-10-17 12:48:18 -07:00
parent 9e9a5b7a53
commit e9c3d6bfb7

View file

@ -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);
});
}