misc_pterodactyl-panel/app/Http/Controllers/Api/Client/Servers/PowerController.php
2020-07-14 21:16:38 -07:00

47 lines
1.3 KiB
PHP

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