2017-10-07 21:16:51 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
|
|
|
|
|
|
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|
|
|
|
|
|
|
class EggFormRequest extends AdminFormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
$rules = [
|
2020-09-26 23:29:26 +00:00
|
|
|
'name' => 'required|string|max:191',
|
2020-04-18 00:52:40 +00:00
|
|
|
'description' => 'nullable|string',
|
2020-12-13 18:13:32 +00:00
|
|
|
'docker_images' => 'required|string',
|
2022-09-25 19:24:54 +00:00
|
|
|
'force_outgoing_ip' => 'sometimes|boolean',
|
2021-01-27 05:08:53 +00:00
|
|
|
'file_denylist' => 'array',
|
2017-10-07 21:16:51 +00:00
|
|
|
'startup' => 'required|string',
|
|
|
|
'config_from' => 'sometimes|bail|nullable|numeric',
|
2020-09-26 23:29:26 +00:00
|
|
|
'config_stop' => 'required_without:config_from|nullable|string|max:191',
|
2017-10-07 21:16:51 +00:00
|
|
|
'config_startup' => 'required_without:config_from|nullable|json',
|
|
|
|
'config_logs' => 'required_without:config_from|nullable|json',
|
|
|
|
'config_files' => 'required_without:config_from|nullable|json',
|
|
|
|
];
|
|
|
|
|
|
|
|
if ($this->method() === 'POST') {
|
|
|
|
$rules['nest_id'] = 'required|numeric|exists:nests,id';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \Illuminate\Contracts\Validation\Validator $validator
|
|
|
|
*/
|
|
|
|
public function withValidator($validator)
|
|
|
|
{
|
|
|
|
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
2021-01-23 20:09:16 +00:00
|
|
|
return (int) $this->input('config_from') !== 0;
|
2017-10-07 21:16:51 +00:00
|
|
|
});
|
|
|
|
}
|
2022-09-25 19:24:54 +00:00
|
|
|
|
|
|
|
public function validated(): array
|
|
|
|
{
|
|
|
|
$data = parent::validated();
|
|
|
|
|
|
|
|
return array_merge($data, [
|
|
|
|
'force_outgoing_ip' => array_get($data, 'force_outgoing_ip', false),
|
|
|
|
]);
|
|
|
|
}
|
2017-10-07 21:16:51 +00:00
|
|
|
}
|