Skip to content

[9.x] Modify DatabaseRule to accept Arrayable instance inside where methods #39621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Illuminate/Validation/Rules/DatabaseRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Validation\Rules;

use Closure;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -81,12 +82,12 @@ public function resolveTableName($table)
* Set a "where" constraint on the query.
*
* @param \Closure|string $column
* @param array|string|int|null $value
* @param \Illuminate\Contracts\Support\Arrayable|array|string|int|null $value
* @return $this
*/
public function where($column, $value = null)
{
if (is_array($value)) {
if ($value instanceof Arrayable || is_array($value)) {
return $this->whereIn($column, $value);
}

Expand All @@ -107,12 +108,12 @@ public function where($column, $value = null)
* Set a "where not" constraint on the query.
*
* @param string $column
* @param array|string $value
* @param \Illuminate\Contracts\Support\Arrayable|array|string $value
* @return $this
*/
public function whereNot($column, $value)
{
if (is_array($value)) {
if ($value instanceof Arrayable || is_array($value)) {
return $this->whereNotIn($column, $value);
}

Expand Down Expand Up @@ -145,10 +146,10 @@ public function whereNotNull($column)
* Set a "where in" constraint on the query.
*
* @param string $column
* @param array $values
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @return $this
*/
public function whereIn($column, array $values)
public function whereIn($column, $values)
{
return $this->where(function ($query) use ($column, $values) {
$query->whereIn($column, $values);
Expand All @@ -159,10 +160,10 @@ public function whereIn($column, array $values)
* Set a "where not in" constraint on the query.
*
* @param string $column
* @param array $values
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @return $this
*/
public function whereNotIn($column, array $values)
public function whereNotIn($column, $values)
{
return $this->where(function ($query) use ($column, $values) {
$query->whereNotIn($column, $values);
Expand Down