--}}
{{-- --------- new files uploaded ----------- --}}
@if($files_uploaded && count($files_uploaded) > 0)
@foreach ($files_uploaded as $index => $new_file)
@endforeach
@endif
{{-- --------- end new files uploaded ----------- --}}
@if( $messages && count($messages) > 0)
@foreach ($messages as $message)
@php
$next = null;
$prev = null;
$iter_temp = $loop->iteration;
$iter = $iter_temp-1;
$iter_prev = $iter_temp-1;
$prev_message;
if($loop->iteration != count($messages)){
$next = $messages->get(++$iter ) ;
}
if($loop->iteration != 1){
$prev = $messages->get(--$iter_prev) ;
}
@endphp
@if($message->message_from == Auth::user()->id)
@if(!$prev || $prev->message_from != $message->message_from)
@php $prev_message = $message; @endphp
@else
@endif
@if($next)
@if($next->message_from != $message->message_from)
{{-- If the prev message it is not from the same user close the div and add time --}}
@else
@if($next && $next->message_from == $message->message_from && (\Carbon\Carbon::parse($message->created_at)->diffForHumans() != \Carbon\Carbon::parse($next->created_at)->diffForHumans()))
@elseif(!$prev && !$next)
@elseif(!$next)
@endif
@endif
@else
{{-- If no next message close the div and show the time --}}