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