Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php
10277 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
4
5
use Pterodactyl\Models\Server;
6
7
class UpdateServerDetailsRequest extends ServerWriteRequest
8
{
9
/**
10
* Rules to apply to a server details update request.
11
*/
12
public function rules(): array
13
{
14
$rules = Server::getRulesForUpdate($this->parameter('server', Server::class));
15
16
return [
17
'external_id' => $rules['external_id'],
18
'name' => $rules['name'],
19
'user' => $rules['owner_id'],
20
'description' => array_merge(['nullable'], $rules['description']),
21
];
22
}
23
24
/**
25
* Convert the posted data into the correct format that is expected
26
* by the application.
27
*/
28
public function validated($key = null, $default = null): array
29
{
30
return [
31
'external_id' => $this->input('external_id'),
32
'name' => $this->input('name'),
33
'owner_id' => $this->input('user'),
34
'description' => $this->input('description'),
35
];
36
}
37
38
/**
39
* Rename some attributes in error messages to clarify the field
40
* being discussed.
41
*/
42
public function attributes(): array
43
{
44
return [
45
'user' => 'User ID',
46
'name' => 'Server Name',
47
];
48
}
49
}
50
51