table($collection)->where($column, 'regex', "/$value/i"); if (!is_null($excludeId) && $excludeId != 'NULL') { $query->where($idColumn ?: 'id', '<>', $excludeId); } foreach ($extra as $key => $extraValue) { $this->addWhere($query, $key, $extraValue); } return $query->count(); } /** * Count the number of objects in a collection with the given values. * * @param string $collection * @param string $column * @param array $values * @param array $extra * @return int */ public function getMultiCount($collection, $column, array $values, array $extra = []) { // Generates a regex like '/(a|b|c)/i' which can query multiple values $regex = '/(' . implode('|', $values) . ')/i'; $query = $this->table($collection)->where($column, 'regex', $regex); foreach ($extra as $key => $extraValue) { $this->addWhere($query, $key, $extraValue); } return $query->count(); } }