Skip to content

Commit bedfcdc

Browse files
author
Curos
committed
fix failing test
1 parent c65af5e commit bedfcdc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol
4141
*/
4242
public function getMultiCount($collection, $column, array $values, array $extra = [])
4343
{
44-
foreach ($values as &$value) {
45-
$value = new MongoRegex("/$value/i");
46-
}
44+
// Generates a regex like '/(a|b|c)/i' which can query multiple values
45+
$regex = '/('.implode('|', $values).')/i';
4746

48-
$query = $this->table($collection)->whereIn($column, $values);
47+
$query = $this->table($collection)->where($column, 'regex', $regex);
4948

5049
foreach ($extra as $key => $extraValue) {
5150
$this->addWhere($query, $key, $extraValue);

0 commit comments

Comments
 (0)