Level 102
You could do a group by on the created at minute
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How could i make when the message is in the same minute as the other message it will only show the time when it was send from that last message in the same minute
this code shows the time from when it was send in the blade
@foreach($chatMessages as $message)
@if( $message->user_id == Auth::user()->id )
<div class="d-flex flex-row justify-content-end mb-1 text-left">
<div class="p-3 ms-3 border" style="border-radius: 15px; background-color: rgba(57, 192, 237,.2); max-width: 50%;">
<p class="small mb-0">{{ $message->message }}</p>
</div>
</div>
@if( $message->created_at->diffForHumans() == $message->created_at->diffForHumans() )
<p class="text-right ms-4 mb-4" style="font-size: 12.5px;"> {{ $message->created_at->diffInSeconds() < 60 ? 'just now' : $message->created_at->diffForHumans() }}</p>
@endif
@else
<div class="d-flex flex-row justify-content-start mb-1 text-left">
<div class="p-3 ms-3" style="border-radius: 12.5px; background-color: #fbfbfb; max-width: 50%;;">
<p class="small mb-0">{{ $message->message }}</p>
</div>
</div>
<p class="text-left ms-4 mb-4" style="font-size: 12.5px;"> {{ $message->created_at->diffInSeconds() < 60 ? 'just now' : $message->created_at->diffForHumans() }}</p>
@endif
@endforeach
Please or to participate in this conversation.