@php $authId = auth()->id(); // Fetch all friendships involving current user $all = \App\Models\FriendShip::where('sender_id', $authId) ->orWhere('receiver_id', $authId) ->get(); // Get a collection of user IDs to exclude $exclude = $all->map(function ($f) use ($authId) { return ($f->sender_id === $authId) ? $f->receiver_id : $f->sender_id; })->push($authId)->values()->all(); // convert to plain array of IDs @endphp @foreach($chats as $chat) @php $chat->userHasLiked = $chat->likes()->where('user_id', auth()->id())->exists(); @endphp
{!! $shortDescription !!} @if (count($words) > 50) {!! $fullDescription !!} View More @endif
{{ $chat->likes_count }}