forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateServerStartupRequest.php
More file actions
55 lines (47 loc) · 1.39 KB
/
UpdateServerStartupRequest.php
File metadata and controls
55 lines (47 loc) · 1.39 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
48
49
50
51
52
53
54
55
<?php
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class UpdateServerStartupRequest extends ApplicationApiRequest
{
/**
* @var string
*/
protected $resource = AdminAcl::RESOURCE_SERVERS;
/**
* @var int
*/
protected $permission = AdminAcl::WRITE;
/**
* Validation rules to run the input against.
*
* @return array
*/
public function rules(): array
{
$data = Server::getUpdateRulesForId($this->getModel(Server::class)->id);
return [
'startup' => $data['startup'],
'environment' => 'present|array',
'egg' => $data['egg_id'],
'pack' => $data['pack_id'],
'image' => $data['image'],
'skip_scripts' => 'present|boolean',
];
}
/**
* Return the validated data in a format that is expected by the service.
*
* @return array
*/
public function validated()
{
$data = parent::validated();
return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([
'egg_id' => array_get($data, 'egg'),
'pack_id' => array_get($data, 'pack'),
'docker_image' => array_get($data, 'image'),
])->toArray();
}
}