@@ -144,10 +144,11 @@ public function create(array $data)
144144 // We know the node exists because of 'exists:nodes,id' in the validation
145145 if (! $ autoDeployed ) {
146146 if (! isset ($ data ['allocation_id ' ])) {
147- $ allocation = Models \Allocation::where ('ip ' , $ data ['ip ' ])->where ('port ' , $ data ['port ' ])-> where ( ' node ' , $ data [ ' node ' ])-> whereNull ( ' assigned_to ' )-> first ( );
147+ $ model = Models \Allocation::where ('ip ' , $ data ['ip ' ])->where ('port ' , $ data ['port ' ]);
148148 } else {
149- $ allocation = Models \Allocation::where ('id ' , $ data ['allocation ' ])-> where ( ' node ' , $ data [ ' node ' ])-> whereNull ( ' assigned_to ' )-> first ( );
149+ $ model = Models \Allocation::where ('id ' , $ data ['allocation_id ' ] );
150150 }
151+ $ allocation = $ model ->where ('node_id ' , $ data ['node_id ' ])->whereNull ('server_id ' )->first ();
151152 }
152153
153154 // Something failed in the query, either that combo doesn't exist, or it is in use.
@@ -159,7 +160,7 @@ public function create(array $data)
159160 // We know the service and option exists because of the validation.
160161 // We need to verify that the option exists for the service, and then check for
161162 // any required variable fields. (fields are labeled env_<env_variable>)
162- $ option = Models \ServiceOption::where ('id ' , $ data ['option ' ])->where ('service_id ' , $ data ['service ' ])->first ();
163+ $ option = Models \ServiceOption::where ('id ' , $ data ['option_id ' ])->where ('service_id ' , $ data ['service_id ' ])->first ();
163164 if (! $ option ) {
164165 throw new DisplayException ('The requested service option does not exist for the specified service. ' );
165166 }
@@ -170,7 +171,7 @@ public function create(array $data)
170171 }
171172
172173 if (! is_null ($ data ['pack_id ' ])) {
173- $ pack = Models \ServicePack::where ('id ' , $ data ['pack_id ' ])->where ('option ' , $ data ['option_id ' ])->first ();
174+ $ pack = Models \ServicePack::where ('id ' , $ data ['pack_id ' ])->where ('option_id ' , $ data ['option_id ' ])->first ();
174175 if (! $ pack ) {
175176 throw new DisplayException ('The requested service pack does not seem to exist for this combination. ' );
176177 }
@@ -264,7 +265,7 @@ public function create(array $data)
264265 'io ' => $ data ['io ' ],
265266 'cpu ' => $ data ['cpu ' ],
266267 'oom_disabled ' => (isset ($ data ['oom_disabled ' ])) ? true : false ,
267- 'allocation ' => $ allocation ->id ,
268+ 'allocation_id ' => $ allocation ->id ,
268269 'service_id ' => $ data ['service_id ' ],
269270 'option_id ' => $ data ['option_id ' ],
270271 'pack_id ' => $ data ['pack_id ' ],
@@ -540,7 +541,7 @@ public function changeBuild($id, array $data)
540541
541542 $ newPorts = true ;
542543 $ server ->allocations ->where ('ip ' , $ ip )->where ('port ' , $ port )->update ([
543- 'assigned_to ' => null ,
544+ 'server_id ' => null ,
544545 ]);
545546 }
546547
@@ -562,8 +563,8 @@ public function changeBuild($id, array $data)
562563 }
563564
564565 $ newPorts = true ;
565- Models \Allocation::where ('ip ' , $ ip )->where ('port ' , $ port )->whereNull ('assigned_to ' )->update ([
566- 'assigned_to ' => $ server ->id ,
566+ Models \Allocation::where ('ip ' , $ ip )->where ('port ' , $ port )->whereNull ('server_id ' )->update ([
567+ 'server_id ' => $ server ->id ,
567568 ]);
568569 }
569570
0 commit comments