// USERS SECTION
//-----swching between users section and recent conversation section by alpine Js-------
//-----End swching between users section and recent conversation section by alpine Js------- // Conversations
@foreach($conversations as $conversation) //---- If I started the chat betwwen us show me the avatar of the other user @if(Auth::user()->id == $conversation->first_user)
user
{{$conversation->seecond_user->name}}

{{\App\Message::where('statu','unreaded')->where('to_user',Auth::user()->id)->where('from_user',$conversation->seecond_user->id)->count()}}

//---- If I was not the one who started the chat betwwen us show me the avatar of the other userwho did it @else
user
{{$conversation->fiirst_user->name}}

{{\App\Message::where('statu','unreaded')->where('to_user',Auth::user()->id)->where('from_user',$conversation->fiirst_user->id)->count()}}

@endif @endforeach
// users section
@foreach($users as $user)
user
{{$user->name}}
@endforeach
//------------------------------------------
@foreach($messages as $message) @if(Auth::user()->id == $message->from_user)

{{$message->body}}

{{$message->created_at}}

@else
user

{{$message->body}}

{{$message->created_at}}

@endif @endforeach