Skip to content

Commit 0e89ecb

Browse files
committed
Handle node:<param> properly when doing server searches
Uses the node name rather than the node’s ID by default.
1 parent 57d62c4 commit 0e89ecb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,21 @@ public function getIndex(Request $request)
6868
$match = str_replace('"', '', $match);
6969
if (strpos($match, ':')) {
7070
list($field, $term) = explode(':', $match);
71-
$field = (strpos($field, '.')) ? $field : 'servers.' . $field;
71+
if ($field === 'node') {
72+
$field = 'nodes.name';
73+
} else if (!strpos($field, '.')) {
74+
$field = 'servers.' . $field;
75+
}
76+
7277
$query->orWhere($field, 'LIKE', '%' . $term . '%');
7378
} else {
7479
$query->where('servers.name', 'LIKE', '%' . $match . '%');
75-
$query->orWhere('servers.username', 'LIKE', '%' . $match . '%');
76-
$query->orWhere('users.email', 'LIKE', '%' . $match . '%');
77-
$query->orWhere('allocations.port', 'LIKE', '%' . $match . '%');
78-
$query->orWhere('allocations.ip', 'LIKE', '%' . $match . '%');
80+
$query->orWhere([
81+
['servers.username', 'LIKE', '%' . $match . '%'],
82+
['users.email', 'LIKE', '%' . $match . '%'],
83+
['allocations.port', 'LIKE', '%' . $match . '%'],
84+
['allocations.ip', 'LIKE', '%' . $match . '%'],
85+
]);
7986
}
8087
}
8188
}

0 commit comments

Comments
 (0)