Pārlūkot izejas kodu

修复:模型setDec方法不支持传参主键ID

Yahoo 4 gadi atpakaļ
vecāks
revīzija
975aa5750b
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  1. 3 0
      cores/BaseModel.php

+ 3 - 0
cores/BaseModel.php

@@ -244,6 +244,9 @@ abstract class BaseModel extends Model
      */
     protected function setDec($where, string $field, float $step = 1)
     {
+        if (is_numeric($where)) {
+            $where = [$this->getPk() => (int)$where];
+        }
         return $this->where($where)->dec($field, $step)->update();
     }