Конвертированный Elaquen Laravel:
$userId = 8790;
$data['conversations'] = Conversation::selectRaw('user_profile.id, conversation_key, user_profile.first_name, user_profile.email')
->where(function ($q) use ($userId) {
$q->where('user_one', $userId)
->orWhere('user_two', $userId);
})
->join('user_profile', function ($join) use ($userId) {
$join->on('user_profile.id', '=', 'conversation.user_one')->where('conversation.user_one', '!=', $userId)
->orOn('user_profile.id', '=', 'conversation.user_two')->where('conversation.user_two', '!=', $userId);
})
->orderBy('conversation_key', 'DESC')
->take(20)
->get();