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',
|
'option' => 'bail|required|numeric|min:1|exists:service_options,id',
|
||||||
'startup' => 'string',
|
'startup' => 'string',
|
||||||
'custom_image_name' => 'required_if:use_custom_image,on',
|
'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) {
|
$validator->sometimes('node', 'bail|required|numeric|min:1|exists:nodes,id', function ($input) {
|
||||||
|
@ -232,6 +233,11 @@ class ServerRepository
|
||||||
$server = new Models\Server;
|
$server = new Models\Server;
|
||||||
$genUuid = $uuid->generate('servers', 'uuid');
|
$genUuid = $uuid->generate('servers', 'uuid');
|
||||||
$genShortUuid = $uuid->generateShort('servers', 'uuidShort', $genUuid);
|
$genShortUuid = $uuid->generateShort('servers', 'uuidShort', $genUuid);
|
||||||
|
|
||||||
|
if (isset($data['custom_id'])) {
|
||||||
|
$server->id = $data['custom_id'];
|
||||||
|
}
|
||||||
|
|
||||||
$server->fill([
|
$server->fill([
|
||||||
'uuid' => $genUuid,
|
'uuid' => $genUuid,
|
||||||
'uuidShort' => $genShortUuid,
|
'uuidShort' => $genShortUuid,
|
||||||
|
@ -994,4 +1000,4 @@ class ServerRepository
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue