joshrainwater / active-users

A Laravel Package for easily retrieving a list of active users and guests that are currently online.
MIT License
89 stars 33 forks source link

methods #3

Closed rohi1386 closed 5 years ago

rohi1386 commented 6 years ago

Hello How do I know if an online user is online or offline? For example, there are no methods such as isonline( ) or isactive( )? I now have a forech( ) of all my friends and I want to show everyone online. How're you?

rohi1386 commented 6 years ago

` @foreach($users as $user)

          <tr
              <td class="text-center">{{$i}}</td>

              <td>{{$user->name}}</td>
              <td>{{$user->name}}</td>
              <td>{{$user->email}}</td>
              <td class="text-danger text-bold">{{$user->level}}</td>

              **************@if($user->Active::users()) //  ******************************
                  <td class="text-center">
                      <button type="button"  class="btn btn-success btn-sm  ">online</button>
                  </td>
              @else
                  <td class="text-center">
                      <button type="button"  class="btn btn-default   btn-sm">offline</button>
                  </td>
              @endif`
joshrainwater commented 5 years ago

Sorry for the late response. I probably would just do Active::users()->contains() or something similar. Active::users() is a collection of Models, so you can just use collection methods to do what you need to do.