Please help convert Raw part to query builder format. I stuck joining it all together
$profile = UserProfiles::select('id')->where('alias', $profileAlias)->first();
$dbRawMessagesCount = '
(SELECT COUNT(pm.id)
FROM profile_messages pm
WHERE pm.to_profile_id='.$profile->id.'
AND pm.from_profile_id=profile_friend.id
AND pm.is_read=0) AS messages_count
';
$friends = ProfileFriend::select(
'profile_friend.*',
DB::raw($dbRawMessagesCount))
->with('friendProfile')
->whereHas('ownerProfile', function ($query) use ($profile) {
return $query->where('id', $profile->id);
})->paginate();
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OZ97ne
via IFTTT
Aucun commentaire:
Enregistrer un commentaire