mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Egg;
|
|
|
|
use App\Http\Requests\Admin\AdminFormRequest;
|
|
use Illuminate\Validation\Validator;
|
|
|
|
class EggFormRequest extends AdminFormRequest
|
|
{
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'name' => 'required|string|max:255',
|
|
'description' => 'nullable|string',
|
|
'docker_images' => 'required|string',
|
|
'force_outgoing_ip' => 'sometimes|boolean',
|
|
'file_denylist' => 'array',
|
|
'startup' => 'required|string',
|
|
'config_from' => 'sometimes|bail|nullable|numeric',
|
|
'config_stop' => 'required_without:config_from|nullable|string|max:255',
|
|
'config_startup' => 'required_without:config_from|nullable|json',
|
|
'config_logs' => 'required_without:config_from|nullable|json',
|
|
'config_files' => 'required_without:config_from|nullable|json',
|
|
];
|
|
|
|
return $rules;
|
|
}
|
|
|
|
public function withValidator(Validator $validator): void
|
|
{
|
|
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
|
return (int) $this->input('config_from') !== 0;
|
|
});
|
|
}
|
|
|
|
public function validated($key = null, $default = null): array
|
|
{
|
|
$data = parent::validated();
|
|
|
|
return array_merge($data, [
|
|
'force_outgoing_ip' => array_get($data, 'force_outgoing_ip', false),
|
|
]);
|
|
}
|
|
}
|