Skip to content

Commit a03add7

Browse files
death-droidDaneEveritt
authored andcommitted
Allow API to set a custom ID for server creation. (pterodactyl#187)
* Allow API to set a custom ID for server creation. Useful when dealing with billing systems such as WHMCS * Correct API code changes based on feedback.
1 parent 1fc9797 commit a03add7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/Repositories/ServerRepository.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public function create(array $data)
8888
'option' => 'bail|required|numeric|min:1|exists:service_options,id',
8989
'startup' => 'string',
9090
'custom_image_name' => 'required_if:use_custom_image,on',
91-
'auto_deploy' => 'sometimes|boolean'
91+
'auto_deploy' => 'sometimes|boolean',
92+
'custom_id' => 'sometimes|required|numeric|unique:servers,id',
9293
]);
9394

9495
$validator->sometimes('node', 'bail|required|numeric|min:1|exists:nodes,id', function ($input) {
@@ -232,6 +233,11 @@ public function create(array $data)
232233
$server = new Models\Server;
233234
$genUuid = $uuid->generate('servers', 'uuid');
234235
$genShortUuid = $uuid->generateShort('servers', 'uuidShort', $genUuid);
236+
237+
if (isset($data['custom_id'])) {
238+
$server->id = $data['custom_id'];
239+
}
240+
235241
$server->fill([
236242
'uuid' => $genUuid,
237243
'uuidShort' => $genShortUuid,
@@ -994,4 +1000,4 @@ public function updateSFTPPassword($id, $password)
9941000

9951001
}
9961002

997-
}
1003+
}

0 commit comments

Comments
 (0)