product = $product; $this->action = $action; } /** * Execute the job. * * @return void */ public function handle(Hosting $hosting) { trans(); $product = ModuleHosting::with('Server', 'Customer')->find($this->product); if (!$product) { throw new \Exception("Can't find product"); } if (!$product->Server) { throw new \Exception('Invalid request.'); } $hosting->url = $product->Server->name; if ($product->Server->apikey) { $hosting->apiKey = $product->Server->apikey; } if ($product->Server->apikey) { $hosting->apiKey = $product->Server->apikey; } $ClientUser = $hosting->CheckUserClient($product->Customer); if ($ClientUser === "Login_Again") { $hosting->username = $product->Server->user; $hosting->password = SignRSA::DecryptFunc($product->Server->password); $AuthLogin = $hosting->LoginServer(); if ($AuthLogin['error']) { throw new \Exception("You have entered incorrect username or password."); } $hosting->apiKey = $AuthLogin['data']['key']; ModuleHostingServer::where('id', $product->Server->id)->update(['apikey' => $AuthLogin['data']['key']]); $ClientUser = $hosting->CheckUserClient($product->Customer); } if ($ClientUser['error'] === true) { throw new \Exception('Invalid request.'); } $statusAction = null; switch ($this->action) { case "Suspend": $statusAction = $hosting->SuspendAccount($ClientUser['data']['0']['id']); break; case "Activate": $statusAction = $hosting->ActivateAccount($ClientUser['data']['0']['id']); break; default: break; } if (isset($statusAction['error'])) { throw new \Exception($statusAction['data']); } } public function failed(Throwable $exception): void { Log::channel('Custom')->info("\r\n"); Log::channel('Custom')->info("================================="); Log::channel('Custom')->info("Thông báo lỗi lúc: " .Carbon::now()); Log::channel('Custom')->info($exception->getMessage()); Log::channel('Custom')->info("================================="); } }