@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
img

{{$chat->user->name ?? ''}}

3 min ago
@if (Auth::check() && \Illuminate\Support\Facades\Auth::user()->hasRole('user')) @if(!in_array($chat->user->id, $exclude)) @endif @else @endif @if (Auth::check() && \Illuminate\Support\Facades\Auth::user()->hasRole('user')) @endif

{{ $chat->title ?? '' }} - {{ $chat->sub_title ?? '' }}

@php $words = explode(' ', $chat->description); $shortDescription = implode(' ', array_slice($words, 0, 50)); $fullDescription = implode(' ', array_slice($words, 50)); @endphp

{!! $shortDescription !!} @if (count($words) > 50) {!! $fullDescription !!} View More @endif

@if (Auth::check() && \Illuminate\Support\Facades\Auth::user()->hasRole('user'))
@endif
@endforeach