Files
panel/app/Http/Controllers/Client/Servers/PowerController.php
2022-07-18 13:18:09 -05:00

37 lines
1020 B
PHP

<?php
namespace App\Http\Controllers\Client\Servers;
use App\Http\Controllers\ApplicationApiController;
use App\Http\Requests\Client\Servers\SendPowerCommandRequest;
use App\Models\Server;
use App\Services\Servers\PowerService;
class PowerController extends ApplicationApiController
{
public function __construct(private PowerService $powerService)
{
}
public function sendCommand(SendPowerCommandRequest $request, Server $server)
{
switch ($request->action) {
case 'start':
$this->powerService->setServer($server)->start();
break;
case 'shutdown':
$this->powerService->setServer($server)->shutdown();
break;
case 'kill':
$this->powerService->setServer($server)->kill();
break;
case 'reboot':
$this->powerService->setServer($server)->reboot();
break;
}
return $this->returnNoContent();
}
}