Files

46 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2018-01-27 12:38:56 -06:00
<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
2018-01-27 12:38:56 -06:00
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Services\Acl\Api\AdminAcl;
2018-01-27 12:38:56 -06:00
class StoreAllocationRequest extends ApplicationApiRequest
{
2022-10-14 10:59:20 -06:00
protected ?string $resource = AdminAcl::RESOURCE_ALLOCATIONS;
2018-01-27 12:38:56 -06:00
2022-10-14 10:59:20 -06:00
protected int $permission = AdminAcl::WRITE;
2018-01-27 12:38:56 -06:00
2026-10-05 18:10:18 -04:00
/**
* @return ValidationRules
*/
2018-01-27 12:38:56 -06:00
public function rules(): array
{
return [
2026-10-05 18:10:18 -04:00
'ip' => ['required', 'string'],
'alias' => ['sometimes', 'nullable', 'string', 'max:191'],
'ports' => ['required', 'array'],
'ports.*' => ['string'],
2018-01-27 12:38:56 -06:00
];
}
2026-10-05 18:10:18 -04:00
/**
2026-10-11 06:53:45 -04:00
* The validated input under the action's field names: ip, ports and alias are its
* allocation_ip, allocation_ports and allocation_alias.
*
2026-10-11 19:54:55 -04:00
* @return array<string, mixed>
2026-10-05 18:10:18 -04:00
*/
2026-10-11 06:53:45 -04:00
public function actionInput(): array
2018-01-27 12:38:56 -06:00
{
2026-10-11 06:53:45 -04:00
$input = parent::actionInput();
2018-01-27 12:38:56 -06:00
return [
2026-10-11 06:53:45 -04:00
'allocation_ip' => $input['ip'] ?? null,
'allocation_ports' => $input['ports'] ?? null,
'allocation_alias' => $input['alias'] ?? null,
2018-01-27 12:38:56 -06:00
];
}
}