Skip to content

Commit

Permalink
模型增加inc和dec方法 配合save方法使用
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jun 24, 2024
1 parent aab3858 commit d644347
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,34 @@ public function isEmpty(): bool
return empty($this->data);
}

/**
* 字段值增长
*
* @param string $field 字段名
* @param float $step 增长值
*
* @return $this
*/
public function inc(string $field, float $step = 1)
{
$this->setAttr($field, ['INC', $step]);
return $this;
}

/**
* 字段值减少.
*
* @param string $field 字段名
* @param float $step 增长值
*
* @return $this
*/
public function dec(string $field, float $step = 1)
{
$this->setAttr($field, ['DEC', $step]);
return $this;
}

/**
* 保存当前数据对象
*
Expand Down

0 comments on commit d644347

Please sign in to comment.