Allow API to set a custom ID for server creation. (#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.
This commit is contained in:
parent
1fc9797458
commit
a03add7e4f
1 changed files with 8 additions and 2 deletions
|
@ -88,7 +88,8 @@ class ServerRepository
|
|||
'option' => 'bail|required|numeric|min:1|exists:service_options,id',
|
||||
'startup' => 'string',
|
||||
'custom_image_name' => 'required_if:use_custom_image,on',
|
||||
'auto_deploy' => 'sometimes|boolean'
|
||||
'auto_deploy' => 'sometimes|boolean',
|
||||
'custom_id' => 'sometimes|required|numeric|unique:servers,id',
|
||||
]);
|
||||
|
||||
$validator->sometimes('node', 'bail|required|numeric|min:1|exists:nodes,id', function ($input) {
|
||||
|
@ -232,6 +233,11 @@ class ServerRepository
|
|||
$server = new Models\Server;
|
||||
$genUuid = $uuid->generate('servers', 'uuid');
|
||||
$genShortUuid = $uuid->generateShort('servers', 'uuidShort', $genUuid);
|
||||
|
||||
if (isset($data['custom_id'])) {
|
||||
$server->id = $data['custom_id'];
|
||||
}
|
||||
|
||||
$server->fill([
|
||||
'uuid' => $genUuid,
|
||||
'uuidShort' => $genShortUuid,
|
||||
|
|
Loading…
Reference in a new issue