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:
parent
57d62c4ed3
commit
0e89ecb427
1 changed files with 12 additions and 5 deletions
|
@ -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 . '%'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue