| @@ 522-536 (lines=15) @@ | ||
| 519 | ||
| 520 | $newPorts = false; |
|
| 521 | // Remove Assignments |
|
| 522 | if (isset($data['remove_allocations'])) { |
|
| 523 | foreach ($data['remove_allocations'] as $allocation) { |
|
| 524 | // Can't remove the assigned IP/Port combo |
|
| 525 | if ((int) $allocation === $server->allocation_id) { |
|
| 526 | continue; |
|
| 527 | } |
|
| 528 | ||
| 529 | $newPorts = true; |
|
| 530 | Models\Allocation::where('id', $allocation)->where('server_id', $server->id)->update([ |
|
| 531 | 'server_id' => null, |
|
| 532 | ]); |
|
| 533 | } |
|
| 534 | ||
| 535 | $server->load('allocations'); |
|
| 536 | } |
|
| 537 | ||
| 538 | // Add Assignments |
|
| 539 | if (isset($data['add_allocations'])) { |
|
| @@ 539-553 (lines=15) @@ | ||
| 536 | } |
|
| 537 | ||
| 538 | // Add Assignments |
|
| 539 | if (isset($data['add_allocations'])) { |
|
| 540 | foreach ($data['add_allocations'] as $allocation) { |
|
| 541 | $model = Models\Allocation::where('id', $allocation)->whereNull('server_id')->first(); |
|
| 542 | if (! $model) { |
|
| 543 | continue; |
|
| 544 | } |
|
| 545 | ||
| 546 | $newPorts = true; |
|
| 547 | $model->update([ |
|
| 548 | 'server_id' => $server->id, |
|
| 549 | ]); |
|
| 550 | } |
|
| 551 | ||
| 552 | $server->load('allocations'); |
|
| 553 | } |
|
| 554 | ||
| 555 | if ($newPorts) { |
|
| 556 | $newBuild['ports|overwrite'] = $server->allocations->groupBy('ip')->map(function ($item) { |
|