Fix bill edit submission group thing.

This commit is contained in:
James Cole
2020-10-19 18:28:39 +02:00
parent 2e3af087e8
commit 30f708ba7a

View File

@@ -142,7 +142,14 @@ class BillUpdateService
$bill->objectGroups()->sync([$objectGroup->id]);
$bill->save();
}
return $bill;
}
// remove if name is empty. Should be overruled by ID.
if ('' === $objectGroupTitle) {
$bill->objectGroups()->sync([]);
$bill->save();
}
// try also with ID:
$objectGroupId = (int)($data['object_group_id'] ?? 0);
if (0 !== $objectGroupId) {
@@ -151,6 +158,11 @@ class BillUpdateService
$bill->objectGroups()->sync([$objectGroup->id]);
$bill->save();
}
return $bill;
}
if(0 === $objectGroupId) {
$bill->objectGroups()->sync([]);
$bill->save();
}
return $bill;