From 893858357d9b67ed132ce4b698f685feb8ca0f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E4=BA=91=E5=B3=B0?= Date: Thu, 1 Sep 2022 16:09:22 +0800 Subject: [PATCH] fix(whereRelation): closure case. --- src/Database/Eloquent/BuilderMixin.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Database/Eloquent/BuilderMixin.php b/src/Database/Eloquent/BuilderMixin.php index 5a9f986..77d8202 100644 --- a/src/Database/Eloquent/BuilderMixin.php +++ b/src/Database/Eloquent/BuilderMixin.php @@ -325,7 +325,11 @@ public function whereRelationIn(): Closure { return function ($relation, $column, $operator = null, $value = null): Builder { return $this->whereHasIn($relation, function ($query) use ($column, $operator, $value) { - $query->where($column, $operator, $value); + if ($column instanceof Closure) { + $column($query); + } else { + $query->where($column, $operator, $value); + } }); }; } @@ -339,7 +343,11 @@ public function orWhereRelationIn(): Closure { return function ($relation, $column, $operator = null, $value = null): Builder { return $this->orWhereHasIn($relation, function ($query) use ($column, $operator, $value) { - $query->where($column, $operator, $value); + if ($column instanceof Closure) { + $column($query); + } else { + $query->where($column, $operator, $value); + } }); }; }