Merge branch 'master' of https://bitbucket.org/Panabonic/faufcc-api
commit
b195353163
|
|
@ -38,12 +38,12 @@ trait HasObjectsTrait {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachObject(NirObject $object, $ord = null, $group = null) {
|
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->moveObjectsSet('forward', $ord, null, $group);
|
||||||
$this->objects()->attach($object->id, ['ord' => $ord ?? 0, 'group' => $group ?? 'default']);
|
$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');
|
$res = $this->objectsByGroup($group)->max('ord');
|
||||||
return ($res !== null) ? ($res + 1) : 0;
|
return ($res !== null) ? ($res + 1) : 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue