44use Illuminate \Database \Schema \Blueprint ;
55use Illuminate \Database \Migrations \Migration ;
66
7- use Pterodactyl \Models \Service ;
8- use Pterodactyl \Models \ServiceOptions ;
9- use Pterodactyl \Models \ServiceVariables ;
10-
117class AddArkServiceOption extends Migration
128{
139 /**
@@ -18,12 +14,12 @@ class AddArkServiceOption extends Migration
1814 public function up ()
1915 {
2016 DB ::transaction (function () {
21- $ service = Service:: select ('id ' )->where ('author ' , 'ptrdctyl-v040-11e6-8b77-86f30ca893d3 ' )->where ('name ' , 'Source Engine ' )->first ();
17+ $ service = DB :: table ( ' services ' )-> select ('id ' )->where ('author ' , 'ptrdctyl-v040-11e6-8b77-86f30ca893d3 ' )->where ('name ' , 'Source Engine ' )->first ();
2218 if (!$ service ) {
2319 exit ('No service could be found. ' );
2420 }
2521
26- $ option = ServiceOptions:: create ([
22+ $ oid = DB :: table ( ' service_options ' )-> getInsertId ([
2723 'parent_service ' => $ service ->id ,
2824 'name ' => 'Ark: Survival Evolved ' ,
2925 'description ' => 'As a man or woman stranded, naked, freezing, and starving on the unforgiving shores of a mysterious island called ARK, use your skill and cunning to kill or tame and ride the plethora of leviathan dinosaurs and other primeval creatures roaming the land. Hunt, harvest resources, craft items, grow crops, research technologies, and build shelters to withstand the elements and store valuables, all while teaming up with (or preying upon) hundreds of other players to survive, dominate... and escape! — Gamepedia: ARK ' ,
@@ -33,8 +29,8 @@ public function up()
3329 'startup ' => 'TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}} '
3430 ]);
3531
36- ServiceVariables:: create ([
37- 'option_id ' => $ option -> id ,
32+ DB :: table ( ' service_variables ' )-> insert ([
33+ 'option_id ' => $ oid ,
3834 'name ' => 'Server Password ' ,
3935 'description ' => 'If specified, players must provide this password to join the server. ' ,
4036 'env_variable ' => 'ARK_PASSWORD ' ,
@@ -45,8 +41,8 @@ public function up()
4541 'regex ' => '/^(\w\.*)$/ '
4642 ]);
4743
48- ServiceVariables:: create ([
49- 'option_id ' => $ option -> id ,
44+ DB :: table ( ' service_variables ' )-> insert ([
45+ 'option_id ' => $ oid ,
5046 'name ' => 'Admin Password ' ,
5147 'description ' => 'If specified, players must provide this password (via the in-game console) to gain access to administrator commands on the server. ' ,
5248 'env_variable ' => 'ARK_ADMIN_PASSWORD ' ,
@@ -57,8 +53,8 @@ public function up()
5753 'regex ' => '/^(\w\.*)$/ '
5854 ]);
5955
60- ServiceVariables:: create ([
61- 'option_id ' => $ option -> id ,
56+ DB :: table ( ' service_variables ' )-> insert ([
57+ 'option_id ' => $ oid ,
6258 'name ' => 'Maximum Players ' ,
6359 'description ' => 'Specifies the maximum number of players that can play on the server simultaneously. ' ,
6460 'env_variable ' => 'SERVER_MAX_PLAYERS ' ,
@@ -80,9 +76,15 @@ public function up()
8076 public function down ()
8177 {
8278 DB ::transaction (function () {
83- $ service = Service::select ('id ' )->where ('author ' , 'ptrdctyl-v040-11e6-8b77-86f30ca893d3 ' )->where ('name ' , 'Source Engine ' )->first ();
84- $ option = ServiceOptions::where ('parent_service ' , $ service ->id )->where ('tag ' , 'ark ' )->delete ();
85- $ variables = ServiceVariables::where ('option_id ' , $ option ->id )->delete ();
79+ $ service = DB ::table ('services ' )->select ('id ' )->where ('author ' , 'ptrdctyl-v040-11e6-8b77-86f30ca893d3 ' )->where ('name ' , 'Source Engine ' )->first ();
80+
81+ if ($ service ) {
82+ $ option = DB ::table ('service_options ' )->where ('parent_service ' , $ service ->id )->where ('tag ' , 'ark ' )->first ();
83+
84+ if ($ option ) {
85+ $ variables = DB ::table ('service_variables ' )->where ('option_id ' , $ option ->id )->delete ();
86+ }
87+ }
8688 });
8789 }
8890}
0 commit comments