@if($type == 'All') @php $users = DB::table('users')->orderBy('last_seen', 'desc')->get(); @endphp @foreach($users as $user) @endforeach
Name Email Status Last Seen
{{$user->name}} {{$user->email}} @if(Cache::has('is_online' . $user->id)) Online @else Offline @endif {{ \Carbon\Carbon::parse($user->last_seen)->diffForHumans() }}
@elseif($type == 'Online') @php $users = DB::table('users')->WhereBetween('last_seen',[now()->subMinutes(3), now()])->orderBy('last_seen', 'desc')->get(); @endphp @foreach($users as $user) @endforeach
Name Email Status Last Seen
{{$user->name}} {{$user->email}} @if(Cache::has('is_online' . $user->id)) Online @endif {{ \Carbon\Carbon::parse($user->last_seen)->diffForHumans() }}
@elseif($type == 'Offline') @php $users = DB::table('users')->where('last_seen','<',[now()->subMinutes(5)])->orderBy('last_seen', 'desc')->get(); @endphp {{-- @php $users = DB::table('users')->where('last_seen','<',Carbon\Carbon::now()->subMinutes(5)->toDateTimeString()); @endphp --}} @foreach($users as $user) @endforeach
Name Email Status Last Seen
{{$user->name}} {{$user->email}} @if(!Cache::has('is_online' . $user->id)) Offline @endif {{ \Carbon\Carbon::parse($user->last_seen)->diffForHumans() }}
@endif