misc_pterodactyl-panel/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php
2022-02-27 10:50:31 -05:00

37 lines
970 B
PHP

<?php
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
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',
];
}
/**
* @param string|null $key
* @param string|array|null $default
* @return mixed
*/
public function validated($key = null, $default = null)
{
$data = parent::validated();
$response = [
'allocation_ip' => $data['ip'],
'allocation_ports' => $data['ports'],
'allocation_alias' => $data['alias'] ?? null,
];
return is_null($key) ? $response : Arr::get($response, $key, $default);
}
}