@foreach($get_messages as $key=>$value)
@php
$startDate = strtotime($value->created_at);
$current_date = time();
$secs = $current_date - $startDate;
$days = $secs / 86400;
$minutes = $secs/60;
$hours = $secs / 3600;
if($days >= 1)
{
$time = intval($days)." days ago";
if(intval($days) <= 1)
{
$time = intval($days)." day ago";
}
}
else{
if($hours >= 1){
$time = intval($hours)." hours ago";
if(intval($hours) <= 1)
{
$time = intval($hours)." hour ago";
}
}
else{
if($minutes >= 1){
$time = intval($minutes)." Minutes ago";
if(intval($minutes) <= 1)
{
$time = intval($minutes)." Minute ago";
}
}
else{
$time = "Just Now";
}
}
}
@endphp
@if($value->from_id == $user_data->id)
@if($key == count($get_messages)-1)
@else
@endif
{{$value->message}}
{{$time}}
@else
@if($key == count($get_messages)-1)
@else
@endif
{{$value->message}}
{{$time}}
@endif
@endforeach