-
app/Helpers/ExtensionHelper.php
Open in GitHubuse App\Models\Product; use App\Models\OrderProduct; class ExtensionHelper { // ... public static function createServer(OrderProduct $product2) { $order = $product2->order()->first(); $product = Product::findOrFail($product2->product_id); if (!isset($product->extension_id)) { return; } $extension = $product->extension; if (!$extension) { return false; } $module = 'App\Extensions\\Servers\\' . $extension->name . '\\' . $extension->name; $extensionName = $extension->name; if (!class_exists($module)) { return false; } $module = new $module($extension); $config = self::loadConfiguration($product, $product2); $configurableOptions = self::loadConfigurableOptions($product2); $user = $order->user; try { $module->createServer($user, $config, $order, $product2, $configurableOptions); } catch (\Exception $e) { self::error($extensionName, 'Error creating server: ' . $e->getMessage() . ' on line ' . $e->getLine() . ' in file ' . $e->getFile() . ' on line ' . $e->getLine(), $e->getTraceAsString()); } } // ... }
-
app/Jobs/Servers/TerminateServer.php
Open in GitHubuse App\Helpers\ExtensionHelper; use App\Models\OrderProduct; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; class TerminateServer implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $tries = 3; public function __construct( public OrderProduct $orderProduct ) {} public function handle(): void { ExtensionHelper::terminateServer($this->orderProduct); } }