misc_pterodactyl-panel/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php

70 lines
1.7 KiB
PHP
Raw Normal View History

2018-01-13 20:08:19 +00:00
<?php
2018-01-20 01:58:57 +00:00
namespace Pterodactyl\Http\Requests\Api\Application\Nodes;
2018-01-13 20:08:19 +00:00
use Pterodactyl\Models\Node;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
2018-01-13 20:08:19 +00:00
class StoreNodeRequest extends ApplicationApiRequest
2018-01-13 20:08:19 +00:00
{
/**
* Validation rules to apply to this request.
*/
public function rules(array $rules = null): array
{
return collect($rules ?? Node::getRules())->only([
2018-01-13 20:08:19 +00:00
'name',
'location_id',
2021-08-02 16:23:58 +00:00
'database_host_id',
2018-01-13 20:08:19 +00:00
'fqdn',
2021-08-02 16:23:58 +00:00
'scheme',
'behind_proxy',
'public',
'listen_port_http',
'public_port_http',
2021-08-02 16:23:58 +00:00
'listen_port_sftp',
'public_port_sftp',
2021-08-02 16:23:58 +00:00
2018-01-13 20:08:19 +00:00
'memory',
'memory_overallocate',
'disk',
'disk_overallocate',
2021-08-02 16:23:58 +00:00
2018-01-13 20:08:19 +00:00
'upload_size',
'daemon_base',
2018-01-13 20:08:19 +00:00
])->mapWithKeys(function ($value, $key) {
return [snake_case($key) => $value];
})->toArray();
}
/**
* Fields to rename for clarity in the API response.
*
* @return array
*/
public function attributes()
{
return [
'daemon_base' => 'Daemon Base Path',
'upload_size' => 'File Upload Size Limit',
'location_id' => 'Location',
'public' => 'Node Visibility',
];
}
/**
* Change the formatting of some data keys in the validated response data
* to match what the application expects in the services.
*
* @return array
*/
public function validated()
{
$response = parent::validated();
$response['daemon_base'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemon_base');
2018-01-13 20:08:19 +00:00
return $response;
}
}