2018-01-20 22:03:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
|
|
|
|
2022-02-27 15:50:25 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2018-01-20 22:03:23 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
|
|
|
class UpdateServerDetailsRequest extends ServerWriteRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Rules to apply to a server details update request.
|
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
2021-01-24 22:30:58 +00:00
|
|
|
$rules = Server::getRulesForUpdate($this->route()->parameter('server')->id);
|
2018-01-20 22:03:23 +00:00
|
|
|
|
|
|
|
return [
|
2018-02-25 20:45:16 +00:00
|
|
|
'external_id' => $rules['external_id'],
|
2018-01-20 22:03:23 +00:00
|
|
|
'name' => $rules['name'],
|
|
|
|
'user' => $rules['owner_id'],
|
2018-01-21 20:45:20 +00:00
|
|
|
'description' => array_merge(['nullable'], $rules['description']),
|
2018-01-20 22:03:23 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the posted data into the correct format that is expected
|
|
|
|
* by the application.
|
2022-02-27 15:50:25 +00:00
|
|
|
*
|
|
|
|
* @param string|null $key
|
|
|
|
* @param string|array|null $default
|
2018-01-20 22:03:23 +00:00
|
|
|
*/
|
2022-02-27 15:50:25 +00:00
|
|
|
public function validated($key = null, $default = null)
|
2018-01-20 22:03:23 +00:00
|
|
|
{
|
2022-02-27 15:50:25 +00:00
|
|
|
$data = [
|
2018-02-25 20:45:16 +00:00
|
|
|
'external_id' => $this->input('external_id'),
|
2018-01-20 22:03:23 +00:00
|
|
|
'name' => $this->input('name'),
|
|
|
|
'owner_id' => $this->input('user'),
|
|
|
|
'description' => $this->input('description'),
|
|
|
|
];
|
2022-02-27 15:50:25 +00:00
|
|
|
|
|
|
|
return is_null($key) ? $data : Arr::get($data, $key, $default);
|
2018-01-20 22:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rename some of the attributes in error messages to clarify the field
|
|
|
|
* being discussed.
|
|
|
|
*/
|
|
|
|
public function attributes(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'user' => 'User ID',
|
|
|
|
'name' => 'Server Name',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|