query('q', '')); if (mb_strlen($q) < 2) { return response()->json(['data' => []]); } $perPage = min(max((int) $request->query('per_page', 6), 1), 12); $items = array_map(function (array $group): array { $group['group_type'] = $group['type'] ?? null; $group['type'] = 'group'; return $group; }, $this->groups->searchCards($q, $request->user(), $perPage)); return response()->json([ 'data' => $items, ]); } }