Skip to content

Commit b75d534

Browse files
committed
改进when方法
1 parent d6e23e6 commit b75d534

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/db/concern/WhereQuery.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,18 +634,18 @@ public function when($condition, Closure | array $query, Closure | array | null
634634

635635
// 根据条件决定执行哪个查询
636636
if ($condition) {
637-
$this->executeQuery($query);
637+
$this->executeQuery($query, $condition);
638638
} elseif ($otherwise) {
639-
$this->executeQuery($otherwise);
639+
$this->executeQuery($otherwise, $condition);
640640
}
641641

642642
return $this;
643643
}
644644

645-
protected function executeQuery(Closure | array $query): void
645+
protected function executeQuery(Closure | array $query, $condition): void
646646
{
647647
if ($query instanceof Closure) {
648-
$query($this);
648+
$query($this, $condition);
649649
} elseif (is_array($query)) {
650650
$this->where($query);
651651
}

0 commit comments

Comments
 (0)