mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Fixed advanced search on supplier, count for PHP7.2
This commit is contained in:
parent
e5121b33e6
commit
5365182c86
|
@ -85,7 +85,7 @@ class AssetsController extends Controller
|
|||
$filter = array();
|
||||
|
||||
if ($request->has('filter')) {
|
||||
$filter = json_decode($request->input('filter'));
|
||||
$filter = json_decode($request->input('filter'), true);
|
||||
}
|
||||
|
||||
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
|
||||
|
@ -217,7 +217,8 @@ class AssetsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
if (count($filter) > 0) {
|
||||
|
||||
if ((!is_null($filter)) && (count($filter)) > 0) {
|
||||
$assets->ByFilter($filter);
|
||||
} elseif ($request->has('search')) {
|
||||
$assets->TextSearch($request->input('search'));
|
||||
|
|
|
@ -1050,9 +1050,17 @@ class Asset extends Depreciable
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($fieldname =='supplier') {
|
||||
$query->where(function ($query) use ($search_val) {
|
||||
$query->whereHas('supplier', function ($query) use ($search_val) {
|
||||
$query->where('suppliers.name', 'LIKE', '%' . $search_val . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (($fieldname!='category') && ($fieldname!='location')
|
||||
if (($fieldname!='category') && ($fieldname!='location') && ($fieldname!='supplier')
|
||||
&& ($fieldname!='status_label') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
|
||||
$query->orWhere('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue