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/UpdateServerStartupRequest.php
10277 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
4
5
use Pterodactyl\Models\Server;
6
use Pterodactyl\Services\Acl\Api\AdminAcl;
7
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
8
9
class UpdateServerStartupRequest extends ApplicationApiRequest
10
{
11
protected ?string $resource = AdminAcl::RESOURCE_SERVERS;
12
13
protected int $permission = AdminAcl::WRITE;
14
15
/**
16
* Validation rules to run the input against.
17
*/
18
public function rules(): array
19
{
20
$data = Server::getRulesForUpdate($this->parameter('server', Server::class));
21
22
return [
23
'startup' => $data['startup'],
24
'environment' => 'present|array',
25
'egg' => $data['egg_id'],
26
'image' => $data['image'],
27
'skip_scripts' => 'present|boolean',
28
];
29
}
30
31
/**
32
* Return the validated data in a format that is expected by the service.
33
*/
34
public function validated($key = null, $default = null): array
35
{
36
$data = parent::validated();
37
38
return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([
39
'egg_id' => array_get($data, 'egg'),
40
'docker_image' => array_get($data, 'image'),
41
])->toArray();
42
}
43
}
44
45