forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerDetailsController.php
More file actions
47 lines (40 loc) · 1.68 KB
/
ServerDetailsController.php
File metadata and controls
47 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\DetailsModificationService;
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest;
class ServerDetailsController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\DetailsModificationService
*/
private $modificationService;
/**
* ServerDetailsController constructor.
*
* @param \Pterodactyl\Services\Servers\DetailsModificationService $modificationService
*/
public function __construct(DetailsModificationService $modificationService)
{
parent::__construct();
$this->modificationService = $modificationService;
}
/**
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function details(UpdateServerDetailsRequest $request, Server $server): array
{
$server = $this->modificationService->returnUpdatedModel()->handle($server, $request->validated());
return $this->fractal->item($server)
->transformWith($this->getTransformer(ServerTransformer::class))
->toArray();
}
}