Files

69 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
2026-10-11 09:04:02 -04:00
use Pterodactyl\Actions\Servers\UpdateServerDetails;
use Pterodactyl\Http\Requests\Concerns\ValidatesExtensionFields;
use Pterodactyl\Models\Server;
class UpdateServerDetailsRequest extends ServerWriteRequest
{
2026-10-11 09:04:02 -04:00
use ValidatesExtensionFields {
actionInput as private inputWithExtensions;
}
/**
2026-10-11 09:04:02 -04:00
* Rules to apply to a server details update request. The Application API keeps its own
* field names; actionInput() hands the values to the action under its names.
2026-10-05 18:10:18 -04:00
*
* @return ValidationRules
*/
public function rules(): array
{
2026-10-11 09:04:02 -04:00
$rules = UpdateServerDetails::rules($this->parameter('server', Server::class));
return [
'external_id' => $rules['external_id'],
'name' => $rules['name'],
'user' => $rules['owner_id'],
2026-10-11 09:04:02 -04:00
'description' => $rules['description'],
];
}
/**
2026-10-11 09:04:02 -04:00
* The validated input under the action's field names: user is its owner_id.
2026-10-05 18:10:18 -04:00
*
2026-10-11 19:54:55 -04:00
* @return array<string, mixed>
*/
2026-10-11 09:04:02 -04:00
public function actionInput(): array
{
2026-10-11 09:04:02 -04:00
$input = $this->inputWithExtensions();
$input['owner_id'] = $input['user'] ?? null;
unset($input['user']);
return $input;
}
/**
2022-10-14 10:59:20 -06:00
* Rename some attributes in error messages to clarify the field
* being discussed.
*/
public function attributes(): array
{
return [
'user' => 'User ID',
'name' => 'Server Name',
];
}
/**
* {@inheritdoc}
*/
protected function extensionFieldsModel(): Server
{
return $this->parameter('server', Server::class);
}
}