misc_pterodactyl-panel/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php

33 lines
920 B
PHP
Raw Normal View History

2018-01-31 02:36:59 +00:00
<?php
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class UpdateServerStartupRequest extends ApplicationApiRequest
{
public function rules(): array
{
2021-01-24 22:30:58 +00:00
$data = Server::getRulesForUpdate($this->route()->parameter('server')->id);
2018-01-31 02:36:59 +00:00
return [
'startup' => $data['startup'],
'environment' => 'present|array',
'egg' => $data['egg_id'],
'image' => $data['image'],
'skip_scripts' => 'present|boolean',
];
}
2021-01-24 22:30:58 +00:00
public function validated(): array
2018-01-31 02:36:59 +00:00
{
$data = parent::validated();
return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([
'egg_id' => array_get($data, 'egg'),
'docker_image' => array_get($data, 'image'),
])->toArray();
}
}