Compare commits

...

1 Commits

Author SHA1 Message Date
as2252258 5a6f6da70a eee 2024-09-02 12:12:39 +08:00
+43 -1
View File
@@ -73,6 +73,48 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
}
/**
* @param string $column
* @param int|float $amount
* @return bool
*/
public function increment(string $column, int|float $amount = 1): bool
{
return (bool)$this->buildCommand($this->builder->mathematics([$column => $amount]))->exec();
}
/**
* @param array $attributes
* @return bool
*/
public function increments(array $attributes): bool
{
return (bool)$this->buildCommand($this->builder->mathematics($attributes))->exec();
}
/**
* @param string $column
* @param int|float $amount
* @return bool
*/
public function decrement(string $column, int|float $amount = 1): bool
{
return (bool)$this->buildCommand($this->builder->mathematics([$column => $amount], '-'))->exec();
}
/**
* @param array $attributes
* @return bool
*/
public function decrements(array $attributes): bool
{
return (bool)$this->buildCommand($this->builder->mathematics($attributes, '-'))->exec();
}
/**
* @throws
*/
@@ -95,7 +137,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
return;
}
if (Context::inCoroutine()) {
Coroutine::create(fn() => $closure($data));
Coroutine::create(fn () => $closure($data));
} else {
call_user_func($closure, $data);
}