misc_pterodactyl-panel/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php

39 lines
977 B
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
2022-12-15 00:05:46 +00:00
use Illuminate\Support\Arr;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class StoreAllocationRequest extends ApplicationApiRequest
{
public function rules(): array
{
return [
'ip' => 'required|string',
'alias' => 'sometimes|nullable|string|max:191',
'ports' => 'required|array',
'ports.*' => 'string',
];
}
2022-12-15 00:05:46 +00:00
/**
* @param string|null $key
* @param string|array|null $default
*
* @return mixed
*/
public function validated($key = null, $default = null)
{
$data = parent::validated();
2022-12-15 00:05:46 +00:00
$response = [
'allocation_ip' => $data['ip'],
'allocation_ports' => $data['ports'],
'allocation_alias' => $data['alias'] ?? null,
];
2022-12-15 00:05:46 +00:00
return is_null($key) ? $response : Arr::get($response, $key, $default);
}
}