$query = User::leftJoin('data1', 'data1.user_id', '=', 'users.id')
->leftJoin('data2', 'data2.user_id', '=', 'users.id')
->select('data1.text as value', 'data2.name as value', DB::raw('count(*) as users_count'))
->groupBy('value')
->orderByDesc('users_count');
select d.value,
count(*) users_count
from user u
left join (select user_id, data1.text value from data1
union all
select user_id, data2.name value from data2
) d on d.user_id = u.id
group by d.value
SELECT t.value, count(*) as users_count
FROM users u
JOIN (
SELECT d1.text as value, d1.user_id FROM data1 d1
UNION
SELECT d2.name as value, d2.user_id FROM data2 d2
) t on t.user_id = u.id
GROUP BY t.value
ORDER BY users_count DESC