*/ #[Endpoint('List available node allocations', 'Returns unassigned allocations for a node.')] #[QueryParam('filter[ip]', 'string', 'Filter allocations by exact IP address.', example: '192.168.1.1')] #[QueryParam('filter[port]', 'integer', 'Filter allocations by exact port.', example: 25565)] #[QueryParam('filter[ip_alias]', 'string', 'Filter allocations by IP alias.', example: 'game.example.com')] #[QueryParam('sort', 'string', 'Sort allocations by id, ip, or port. Prefix with a hyphen for descending order.', example: 'port')] #[QueryParam('per_page', 'integer', 'Results to return per page.', example: 50)] #[ResponseFromTransformer(AllocationTransformer::class, Allocation::class, description: 'Available allocations returned.', collection: true, resourceKey: 'allocation', paginate: [IlluminatePaginatorAdapter::class, 50])] public function __invoke(GetAllocationsRequest $request, Node $node): array { $allocations = QueryBuilder::for($node->allocations()->whereNull('server_id')) ->allowedFilters([ AllowedFilter::exact('ip'), AllowedFilter::exact('port'), 'ip_alias', ]) ->allowedSorts(['id', 'ip', 'port']) ->paginate($request->perPage()); return Fractal::collection($allocations) ->transformWith($this->getTransformer(AllocationTransformer::class)) ->toResponseArray(); } }