@@ -86,6 +86,7 @@ public function create(array $data)
8686 'disk ' => 'required|numeric|min:0 ' ,
8787 'service ' => 'bail|required|numeric|min:1|exists:services,id ' ,
8888 'option ' => 'bail|required|numeric|min:1|exists:service_options,id ' ,
89+ 'pack ' => 'bail|required|numeric|min:0 '
8990 'startup' => 'string',
9091 'custom_image_name ' => 'required_if:use_custom_image,on ' ,
9192 'auto_deploy ' => 'sometimes|boolean '
@@ -161,6 +162,18 @@ public function create(array $data)
161162 throw new DisplayException ('The requested service option does not exist for the specified service. ' );
162163 }
163164
165+ // Validate the Pack
166+ if ($ data ['pack ' ] === 0 ) {
167+ $ data ['pack ' ] = null ;
168+ }
169+
170+ if (!is_null ($ data ['pack ' ])) {
171+ $ pack = Models \ServicePack::where ('id ' , $ data ['pack ' ])->where ('option ' , $ data ['option ' ])->first ();
172+ if (!$ pack ) {
173+ throw new DisplayException ('The requested service pack does not seem to exist for this combination. ' );
174+ }
175+ }
176+
164177 // Load up the Service Information
165178 $ service = Models \Service::find ($ option ->parent_service );
166179
@@ -248,6 +261,7 @@ public function create(array $data)
248261 'allocation ' => $ allocation ->id ,
249262 'service ' => $ data ['service ' ],
250263 'option ' => $ data ['option ' ],
264+ 'pack ' => $ data ['pack ' ],
251265 'startup ' => $ data ['startup ' ],
252266 'daemonSecret ' => $ uuid ->generate ('servers ' , 'daemonSecret ' ),
253267 'image ' => (isset ($ data ['custom_image_name ' ])) ? $ data ['custom_image_name ' ] : $ option ->docker_image ,
@@ -297,27 +311,28 @@ public function create(array $data)
297311 'build ' => [
298312 'default ' => [
299313 'ip ' => $ allocation ->ip ,
300- 'port ' => (int ) $ allocation ->port
314+ 'port ' => (int ) $ allocation ->port ,
301315 ],
302316 'ports ' => [
303- (string ) $ allocation ->ip => [ (int ) $ allocation ->port ]
317+ (string ) $ allocation ->ip => [ (int ) $ allocation ->port ],
304318 ],
305319 'env ' => $ environmentVariables ,
306320 'memory ' => (int ) $ server ->memory ,
307321 'swap ' => (int ) $ server ->swap ,
308322 'io ' => (int ) $ server ->io ,
309323 'cpu ' => (int ) $ server ->cpu ,
310324 'disk ' => (int ) $ server ->disk ,
311- 'image ' => (isset ($ data ['custom_image_name ' ])) ? $ data ['custom_image_name ' ] : $ option ->docker_image
325+ 'image ' => (isset ($ data ['custom_image_name ' ])) ? $ data ['custom_image_name ' ] : $ option ->docker_image ,
312326 ],
313327 'service ' => [
314328 'type ' => $ service ->file ,
315- 'option ' => $ option ->tag
329+ 'option ' => $ option ->tag ,
330+ 'pack ' => (isset ($ pack )) ? $ pack ->uuid : null ,
316331 ],
317332 'keys ' => [
318- (string ) $ server ->daemonSecret => $ this ->daemonPermissions
333+ (string ) $ server ->daemonSecret => $ this ->daemonPermissions ,
319334 ],
320- 'rebuild ' => false
335+ 'rebuild ' => false ,
321336 ]
322337 ]);
323338
0 commit comments