コード例 #1
0
ファイル: NodeController.php プロジェクト: Pterodactyl/Panel
 /**
  * Delete Node
  *
  * @Delete("/nodes/{id}")
  * @Versions({"v1"})
  * @Parameters({
  *      @Parameter("id", type="integer", required=true, description="The ID of the node."),
  * })
  * @Response(204)
  */
 public function delete(Request $request, $id)
 {
     try {
         $node = new NodeRepository();
         $node->delete($id);
         return $this->response->noContent();
     } catch (DisplayException $ex) {
         throw new ResourceException($ex->getMessage());
     } catch (\Exception $e) {
         throw new ServiceUnavailableHttpException('An error occured while attempting to delete this node.');
     }
 }
コード例 #2
0
ファイル: NodesController.php プロジェクト: Pterodactyl/Panel
 public function postAllocations(Request $request, $id)
 {
     $processedData = [];
     foreach ($request->input('allocate_ip') as $ip) {
         if (!array_key_exists($ip, $processedData)) {
             $processedData[$ip] = [];
         }
     }
     foreach ($request->input('allocate_port') as $portid => $ports) {
         if (array_key_exists($portid, $request->input('allocate_ip'))) {
             $json = json_decode($ports);
             if (json_last_error() === 0 && !empty($json)) {
                 foreach ($json as &$parsed) {
                     array_push($processedData[$request->input('allocate_ip')[$portid]], $parsed->value);
                 }
             }
         }
     }
     try {
         if (empty($processedData)) {
             throw new DisplayException('It seems that no data was passed to this function.');
         }
         $node = new NodeRepository();
         $node->addAllocations($id, $processedData);
         Alert::success('Successfully added new allocations to this node.')->flash();
     } catch (DisplayException $e) {
         Alert::danger($e->getMessage())->flash();
     } catch (\Exception $e) {
         Log::error($e);
         Alert::danger('An unhandled exception occured while attempting to add allocations this node. Please try again.')->flash();
     } finally {
         return redirect()->route('admin.nodes.view', ['id' => $id, 'tab' => 'tab_allocation']);
     }
 }