private function shiftLeftRight($key, $delta, ModelInterface $model = null)
{
$owner = $model ?: $this->getOwner();
foreach ([$this->leftAttribute, $this->rightAttribute] as $attribute) {
$condition = $attribute . '>=' . $key;
if ($this->hasManyRoots) {
$condition .= ' AND ' . $this->rootAttribute . '=' . $owner->{$this->rootAttribute};
}
foreach ($owner::find($condition) as $i) {
/** @var ModelInterface $i */
if ($i->update([$attribute => $i->{$attribute} + $delta]) == false) {
$this->db->rollback();
$this->ignoreEvent = false;
return false;
}
}
}
return true;
}