The issue seems to be with the use of a subquery in the select statement. Instead, you can try using a left join and group by clause to get the desired result. Here's an example:
$itemCategories = ItemCategory::select('item_categories.name', DB::raw('count(item_clicked_counts.id) as item_clicked_counts_count'))
->leftJoin('items', 'item_categories.id', '=', 'items.item_category_id')
->leftJoin('item_clicked_counts', 'items.id', '=', 'item_clicked_counts.item_id')
->where('items.active', true)
->whereBetween('item_clicked_counts.created_at', [$dateStart->startOfDay(), $dateEnd->endOfDay()])
->where('item_clicked_counts.page_content_id', $pageContentId)
->where('item_clicked_counts.locale', $locale)
->groupBy('item_categories.name')
->orderBy('item_categories.name', 'asc')
->get();
This query uses left joins to join the three tables and then groups the result by the item category name. The count of item_clicked_counts is calculated using the count function and the where conditions are added to filter the result.