Move the primary allocation when it is removed from a server
This commit is contained in:
1 parent
72779c7ea6
commit
ddaef93768
6 files changed
+82
-4
No files matched your search
+2
-2
@@ -117,7 +117,7 @@ class AllocationsRelationManager extends RelationManager
|
||||
->after(function (Allocation $allocation) {
|
||||
$allocation->update(Allocation::RELEASE_ATTRIBUTES);
|
||||
|
||||
if (!$this->getOwnerRecord()->allocation_id) {
|
||||
if (!$this->getOwnerRecord()->allocation_id || $this->getOwnerRecord()->allocation_id === $allocation->id) {
|
||||
$this->getOwnerRecord()->update(['allocation_id' => $this->getOwnerRecord()->allocations()->first()?->id]);
|
||||
}
|
||||
}),
|
||||
@@ -128,7 +128,7 @@ class AllocationsRelationManager extends RelationManager
|
||||
->after(function (Collection $records) {
|
||||
Allocation::whereIn('id', $records->pluck('id'))->update(Allocation::RELEASE_ATTRIBUTES);
|
||||
|
||||
if (!$this->getOwnerRecord()->allocation_id) {
|
||||
if (!$this->getOwnerRecord()->allocation_id || $records->contains('id', $this->getOwnerRecord()->allocation_id)) {
|
||||
$this->getOwnerRecord()->update(['allocation_id' => $this->getOwnerRecord()->allocations()->first()?->id]);
|
||||
}
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user