Skip to content

Commit

Permalink
改进when方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 10, 2024
1 parent d6e23e6 commit b75d534
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/db/concern/WhereQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,18 @@ public function when($condition, Closure | array $query, Closure | array | null

// 根据条件决定执行哪个查询
if ($condition) {
$this->executeQuery($query);
$this->executeQuery($query, $condition);
} elseif ($otherwise) {
$this->executeQuery($otherwise);
$this->executeQuery($otherwise, $condition);
}

return $this;
}

protected function executeQuery(Closure | array $query): void
protected function executeQuery(Closure | array $query, $condition): void
{
if ($query instanceof Closure) {
$query($this);
$query($this, $condition);
} elseif (is_array($query)) {
$this->where($query);
}
Expand Down

0 comments on commit b75d534

Please sign in to comment.