2017-06-18 00:48:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Admin;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\DatabaseHost;
|
2022-10-14 16:59:20 +00:00
|
|
|
use Illuminate\Contracts\Validation\Validator;
|
2017-06-18 00:48:31 +00:00
|
|
|
|
|
|
|
class DatabaseHostFormRequest extends AdminFormRequest
|
|
|
|
{
|
2022-10-14 16:59:20 +00:00
|
|
|
public function rules(): array
|
2017-06-18 00:48:31 +00:00
|
|
|
{
|
2017-07-22 18:55:30 +00:00
|
|
|
if ($this->method() !== 'POST') {
|
2019-09-05 05:26:28 +00:00
|
|
|
return DatabaseHost::getRulesForUpdate($this->route()->parameter('host'));
|
2017-06-18 00:48:31 +00:00
|
|
|
}
|
|
|
|
|
2019-09-05 05:26:28 +00:00
|
|
|
return DatabaseHost::getRules();
|
2017-06-18 00:48:31 +00:00
|
|
|
}
|
2018-02-18 19:43:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modify submitted data before it is passed off to the validator.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
protected function getValidatorInstance(): Validator
|
2018-02-18 19:43:54 +00:00
|
|
|
{
|
2021-01-23 20:33:34 +00:00
|
|
|
if (!$this->filled('node_id')) {
|
2018-02-18 19:43:54 +00:00
|
|
|
$this->merge(['node_id' => null]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getValidatorInstance();
|
|
|
|
}
|
2017-06-18 00:48:31 +00:00
|
|
|
}
|