2018-01-27 18:38:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
|
|
|
|
|
|
|
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
|
|
|
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
|
|
|
|
|
|
|
class StoreAllocationRequest extends ApplicationApiRequest
|
|
|
|
{
|
2022-10-14 16:59:20 +00:00
|
|
|
protected ?string $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
2018-01-27 18:38:56 +00:00
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
protected int $permission = AdminAcl::WRITE;
|
2018-01-27 18:38:56 +00:00
|
|
|
|
|
|
|
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-10-14 16:59:20 +00:00
|
|
|
public function validated($key = null, $default = null): array
|
2018-01-27 18:38:56 +00:00
|
|
|
{
|
|
|
|
$data = parent::validated();
|
|
|
|
|
|
|
|
return [
|
|
|
|
'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
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|