sergeybodin 2023-09-07 18:00:52 +03:00
commit b195353163
1 changed files with 2 additions and 2 deletions

View File

@ -38,12 +38,12 @@ trait HasObjectsTrait {
}
public function attachObject(NirObject $object, $ord = null, $group = null) {
$ord = ($ord === null) ? $this->getMaxOrd($group) : $ord;
$ord = ($ord === null) ? $this->getMaxObjectOrd($group) : $ord;
$this->moveObjectsSet('forward', $ord, null, $group);
$this->objects()->attach($object->id, ['ord' => $ord ?? 0, 'group' => $group ?? 'default']);
}
public function getMaxOrd($group = null): int {
public function getMaxObjectOrd($group = null): int {
$res = $this->objectsByGroup($group)->max('ord');
return ($res !== null) ? ($res + 1) : 0;
}