@if ($showAllCheckins) Check-ins @else Recent Check-ins @endif

    @if($showAllCheckins) @php $checkinsList = array_reverse($trip->checkins) @endphp @else @php $checkinsList = array_slice(array_reverse($trip->checkins), 0, 10) @endphp @endif @foreach($checkinsList as $checkin)
  1. {{ $checkin->title ?? "[No title]" }}

    {!! render_date_difference($trip->updated_at) !!}

    {{ $checkin->note ?? "[No note]" }} @if($checkin->image_url) @endif
  2. @endforeach
@if (!$showAllCheckins)

Show all checkins

@endif
@php function render_date_difference ($start_time) { $minute = 60; $hour = 60 * 60; $day = 3600 * 24; $week = 86400 * 7; $month = 604800 * 4; $year = 2629800 * 12; $start_time_dt = new DateTime($start_time); $now = new DateTime(); $trip_start_difference = intval(($now->getTimestamp() - $start_time_dt->getTimestamp())); $start_tag = ''; $end_tag = "ago"; $unit = null; $div = 1; if ($trip_start_difference < $minute) { $unit = ' seconds '; } else if ($trip_start_difference < $hour) { $div = 60; $unit = ' minutes '; } else if ($trip_start_difference < $day) { $div = 3600; $unit = ' hours '; } else if ($trip_start_difference < $week) { $div = 86400; $unit = ' days '; } else if ($trip_start_difference < $month) { $div = 604800; $unit = ' weeks '; } else if ($trip_start_difference < $year) { $div = 2629800; $unit = ' months '; } else { $div = 31557600; $unit = ' years '; } return $start_tag . (floor( $trip_start_difference / $div )) . $unit . $end_tag; } @endphp