*/ public function toArray(Request $request): array { $maxItems = 5; return [ 'items' => collect(range(0, $maxItems - 1)) ->filter(fn ($index) => $this->{"item$index"}) ->map(fn ($index) => [ 'vnum' => $this->{"item$index"}->vnum, 'name' => $this->{"item$index"}->locale_name, 'count' => $this->{"count$index"}, ]), 'cost' => $this->cost, 'probability' => $this->prob, ]; } }