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
|
@ -68,14 +68,21 @@ class ServersController extends Controller
|
||||||
$match = str_replace('"', '', $match);
|
$match = str_replace('"', '', $match);
|
||||||
if (strpos($match, ':')) {
|
if (strpos($match, ':')) {
|
||||||
list($field, $term) = explode(':', $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 . '%');
|
$query->orWhere($field, 'LIKE', '%' . $term . '%');
|
||||||
} else {
|
} else {
|
||||||
$query->where('servers.name', 'LIKE', '%' . $match . '%');
|
$query->where('servers.name', 'LIKE', '%' . $match . '%');
|
||||||
$query->orWhere('servers.username', 'LIKE', '%' . $match . '%');
|
$query->orWhere([
|
||||||
$query->orWhere('users.email', 'LIKE', '%' . $match . '%');
|
['servers.username', 'LIKE', '%' . $match . '%'],
|
||||||
$query->orWhere('allocations.port', 'LIKE', '%' . $match . '%');
|
['users.email', 'LIKE', '%' . $match . '%'],
|
||||||
$query->orWhere('allocations.ip', 'LIKE', '%' . $match . '%');
|
['allocations.port', 'LIKE', '%' . $match . '%'],
|
||||||
|
['allocations.ip', 'LIKE', '%' . $match . '%'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue