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

42 lines
1 KiB
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
{
/**
* @var \Pterodactyl\Repositories\Wings\DaemonPowerRepository
2018-03-01 04:51:04 +00:00
*/
private $repository;
/**
* 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();
}
}