2018-01-20 16:03:23 -06:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-01-20 16:03:23 -06:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
|
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Server;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Validation\ServerRules;
|
2018-01-20 16:03:23 -06:00
|
|
|
|
|
|
|
|
class UpdateServerDetailsRequest extends ServerWriteRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Rules to apply to a server details update request.
|
2026-10-05 18:10:18 -04:00
|
|
|
*
|
|
|
|
|
* @return ValidationRules
|
2018-01-20 16:03:23 -06:00
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
$rules = ServerRules::rules($this->parameter('server', Server::class));
|
2018-01-20 16:03:23 -06:00
|
|
|
|
|
|
|
|
return [
|
2018-02-25 14:45:16 -06:00
|
|
|
'external_id' => $rules['external_id'],
|
2018-01-20 16:03:23 -06:00
|
|
|
'name' => $rules['name'],
|
|
|
|
|
'user' => $rules['owner_id'],
|
2018-01-21 14:45:20 -06:00
|
|
|
'description' => array_merge(['nullable'], $rules['description']),
|
2018-01-20 16:03:23 -06:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert the posted data into the correct format that is expected
|
|
|
|
|
* by the application.
|
2026-10-05 18:10:18 -04:00
|
|
|
*
|
|
|
|
|
* @return ServerDetailsModificationData
|
2018-01-20 16:03:23 -06:00
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
public function payload(): array
|
2018-01-20 16:03:23 -06:00
|
|
|
{
|
|
|
|
|
return [
|
2026-10-05 18:10:18 -04:00
|
|
|
'external_id' => $this->filled('external_id') ? $this->string('external_id')->toString() : null,
|
|
|
|
|
'name' => $this->string('name')->toString(),
|
|
|
|
|
'owner_id' => $this->integer('user'),
|
|
|
|
|
'description' => $this->filled('description') ? $this->string('description')->toString() : null,
|
2018-01-20 16:03:23 -06:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-10-14 10:59:20 -06:00
|
|
|
* Rename some attributes in error messages to clarify the field
|
2018-01-20 16:03:23 -06:00
|
|
|
* being discussed.
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'user' => 'User ID',
|
|
|
|
|
'name' => 'Server Name',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|