A free open source IT asset/license management system
Full text search fixes - addresses laravel bug :(
snipee9c3d6bfb79d
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex b27fe9f0aa..fbcf9f2486 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -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);+ });}