2018-03-01 04:51:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
use Pterodactyl\Models\Server;
|
2022-07-04 22:11:53 +00:00
|
|
|
use Pterodactyl\Facades\Activity;
|
2019-09-06 04:41:20 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* PowerController constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private DaemonPowerRepository $repository)
|
2018-03-01 04:51:04 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a power action to a server.
|
|
|
|
*/
|
2019-09-06 04:41:20 +00:00
|
|
|
public function index(SendPowerRequest $request, Server $server): Response
|
2018-03-01 04:51:04 +00:00
|
|
|
{
|
2019-09-06 04:41:20 +00:00
|
|
|
$this->repository->setServer($server)->send(
|
|
|
|
$request->input('signal')
|
|
|
|
);
|
2018-03-01 04:51:04 +00:00
|
|
|
|
2022-07-04 22:11:53 +00:00
|
|
|
Activity::event(strtolower("server:power.{$request->input('signal')}"))->log();
|
|
|
|
|
2018-03-01 04:51:04 +00:00
|
|
|
return $this->returnNoContent();
|
|
|
|
}
|
|
|
|
}
|