Handle node:<param> properly when doing server searches

Uses the node name rather than the node’s ID by default.
This commit is contained in:
Dane Everitt 2016-11-26 16:19:25 -05:00
parent 57d62c4ed3
commit 0e89ecb427
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -68,14 +68,21 @@ class ServersController extends Controller
$match = str_replace('"', '', $match);
if (strpos($match, ':')) {
list($field, $term) = explode(':', $match);
$field = (strpos($field, '.')) ? $field : 'servers.' . $field;
if ($field === 'node') {
$field = 'nodes.name';
} else if (!strpos($field, '.')) {
$field = 'servers.' . $field;
}
$query->orWhere($field, 'LIKE', '%' . $term . '%');
} else {
$query->where('servers.name', 'LIKE', '%' . $match . '%');
$query->orWhere('servers.username', 'LIKE', '%' . $match . '%');
$query->orWhere('users.email', 'LIKE', '%' . $match . '%');
$query->orWhere('allocations.port', 'LIKE', '%' . $match . '%');
$query->orWhere('allocations.ip', 'LIKE', '%' . $match . '%');
$query->orWhere([
['servers.username', 'LIKE', '%' . $match . '%'],
['users.email', 'LIKE', '%' . $match . '%'],
['allocations.port', 'LIKE', '%' . $match . '%'],
['allocations.ip', 'LIKE', '%' . $match . '%'],
]);
}
}
}