2018-01-27 18:38:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
|
|
|
|
|
2022-12-15 00:05:46 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2018-01-27 18:38:56 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
|
|
|
|
|
|
|
class StoreAllocationRequest extends ApplicationApiRequest
|
|
|
|
{
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'ip' => 'required|string',
|
2020-09-26 23:29:26 +00:00
|
|
|
'alias' => 'sometimes|nullable|string|max:191',
|
2018-01-27 18:38:56 +00:00
|
|
|
'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)
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
|
|
|
$data = parent::validated();
|
|
|
|
|
2022-12-15 00:05:46 +00:00
|
|
|
$response = [
|
2018-01-27 18:38:56 +00:00
|
|
|
'allocation_ip' => $data['ip'],
|
|
|
|
'allocation_ports' => $data['ports'],
|
2019-08-03 20:03:54 +00:00
|
|
|
'allocation_alias' => $data['alias'] ?? null,
|
2018-01-27 18:38:56 +00:00
|
|
|
];
|
2022-12-15 00:05:46 +00:00
|
|
|
|
|
|
|
return is_null($key) ? $response : Arr::get($response, $key, $default);
|
2018-01-27 18:38:56 +00:00
|
|
|
}
|
|
|
|
}
|