diff --git a/src/Illuminate/Validation/Rules/DatabaseRule.php b/src/Illuminate/Validation/Rules/DatabaseRule.php index f18bcbf5e111..ae410ca35acb 100644 --- a/src/Illuminate/Validation/Rules/DatabaseRule.php +++ b/src/Illuminate/Validation/Rules/DatabaseRule.php @@ -51,11 +51,15 @@ public function __construct($table, $column = 'NULL') * Set a "where" constraint on the query. * * @param string $column - * @param string $value + * @param string|array $value * @return $this */ public function where($column, $value = null) { + if (is_array($value)) { + return $this->whereIn($column, $value); + } + if ($column instanceof Closure) { return $this->using($column); } @@ -69,11 +73,15 @@ public function where($column, $value = null) * Set a "where not" constraint on the query. * * @param string $column - * @param string $value + * @param string|array $value * @return $this */ public function whereNot($column, $value) { + if (is_array($value)) { + return $this->whereNotIn($column, $value); + } + return $this->where($column, '!'.$value); } @@ -103,11 +111,15 @@ public function whereNotNull($column) * Set a "where in" constraint on the query. * * @param string $column - * @param array $values + * @param string|array $values * @return $this */ - public function whereIn($column, array $values) + public function whereIn($column, $values) { + if (! is_array($values)) { + return $this->where($column, $values); + } + return $this->where(function ($query) use ($column, $values) { $query->whereIn($column, $values); }); @@ -117,11 +129,15 @@ public function whereIn($column, array $values) * Set a "where not in" constraint on the query. * * @param string $column - * @param array $values + * @param string|array $values * @return $this */ - public function whereNotIn($column, array $values) + public function whereNotIn($column, $values) { + if (! is_array($values)) { + return $this->whereNot($column, $values); + } + return $this->where(function ($query) use ($column, $values) { $query->whereNotIn($column, $values); });