From a3ebda57ace30dd93e56c2e4924e3c33ef056658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 26 Mar 2021 14:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Traits/QueryTrait.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Database/Traits/QueryTrait.php b/Database/Traits/QueryTrait.php index 9efbfc46..fb979107 100644 --- a/Database/Traits/QueryTrait.php +++ b/Database/Traits/QueryTrait.php @@ -65,11 +65,17 @@ trait QueryTrait /** * @param string $column * @param callable $callable - * @return CaseWhen + * @return $this */ - public function case(string $column, callable $callable): CaseWhen + public function case(string $column, callable $callable): static { - return call_user_func($callable, new CaseWhen($column, $this)); + $caseWhen = new CaseWhen($column, $this); + + call_user_func($callable, $caseWhen); + + $this->where[] = $caseWhen->end(); + + return $this; }