misc_pterodactyl-panel/app/Http/Controllers/Api/Client/Servers/PowerController.php

39 lines
1,005 B
PHP
Raw Normal View History

2018-03-01 04:51:04 +00:00
<?php
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
2018-03-01 04:51:04 +00:00
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest;
class PowerController extends ClientApiController
{
2021-03-05 17:03:12 +00:00
private DaemonPowerRepository $repository;
2018-03-01 04:51:04 +00:00
/**
* PowerController constructor.
*/
public function __construct(DaemonPowerRepository $repository)
2018-03-01 04:51:04 +00:00
{
parent::__construct();
$this->repository = $repository;
}
/**
* Send a power action to a server.
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
2018-03-01 04:51:04 +00:00
*/
public function index(SendPowerRequest $request, Server $server): Response
2018-03-01 04:51:04 +00:00
{
$this->repository->setServer($server)->send(
$request->input('signal')
);
2018-03-01 04:51:04 +00:00
return $this->returnNoContent();
}
}