sortable bug fix
parent
41a7cd65cf
commit
308a84f889
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue