Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5453807f2 | |||
| 5a6f6da70a |
+43
-1
@@ -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
|
* @throws
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +137,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Context::inCoroutine()) {
|
if (Context::inCoroutine()) {
|
||||||
Coroutine::create(fn() => $closure($data));
|
Coroutine::create(fn () => $closure($data));
|
||||||
} else {
|
} else {
|
||||||
call_user_func($closure, $data);
|
call_user_func($closure, $data);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -223,8 +223,8 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
*/
|
*/
|
||||||
public function getPrimaryValue(): ?int
|
public function getPrimaryValue(): ?int
|
||||||
{
|
{
|
||||||
if ($this->hasPrimary()) {
|
if ($this->hasPrimary() && isset($this->_oldAttributes[$this->getPrimary()])) {
|
||||||
return (int)$this->_oldAttributes[$this->getPrimary()] ?? null;
|
return (int)$this->_oldAttributes[$this->getPrimary()];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user