misc_pterodactyl-panel/app/Http/Controllers/Api/Client/Servers/PowerController.php
Matthew Penner cbcf62086f
Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00

35 lines
958 B
PHP

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