@foreach ($messages as $msg) @php if ($msg->last()->from_user_id == Auth::user()->id && $msg->last()->to()->id != Auth::user()->id) { $avatar = $msg->last()->to()->avatar; $name = $msg->last()->to()->hide_name == 'yes' ? $msg->last()->to()->username : $msg->last()->to()->name; $userID = $msg->last()->to()->id; $username = $msg->last()->to()->username; $icon = $msg->last()->status == 'readed' ? '' : ''; } else if ($msg->last()->from_user_id == Auth::user()->id){ $avatar = $msg->last()->to()->avatar; $name = $msg->last()->to()->hide_name == 'yes' ? $msg->last()->to()->username : $msg->last()->to()->name; $userID = $msg->last()->to()->id; $username = $msg->last()->to()->username; $icon = null; } else { $avatar = $msg->last()->from()->avatar; $name = $msg->last()->from()->hide_name == 'yes' ? $msg->last()->from()->username : $msg->last()->from()->name; $userID = $msg->last()->from()->id; $username = $msg->last()->from()->username; $icon = null; } switch ($msg->last()->format) { case 'image': $iconMedia = ' '; $format = trans('general.image'); break; case 'video': $iconMedia = ' '; $format = trans('general.video'); break; case 'music': $iconMedia = ' '; $format = trans('general.music'); break; case 'zip': $iconMedia = ' '; $format = trans('general.zip'); break; default: $iconMedia = null; $format = null; } if ($msg->last()->tip == 'yes') { $iconMedia = ''.trans('general.tip'); } /* New - Readed */ if ($msg->last()->status == 'new' && $msg->last()->from()->id != Auth::user()->id) { $styleStatus = ' active'; } else { $styleStatus = null; } // Messages $messagesCount = Messages::where('from_user_id', $userID)->where('to_user_id', Auth::user()->id)->where('status','new')->count(); @endphp
@endforeach @if ($messages->hasMorePages())