[Vuejs]-Check if user is online with laravel models , return value to vue

1πŸ‘

βœ…

I haven’t tested this, but is should be something like this.


<td>
     <span class="badge badge-warning">{{user.last_online_at}}</span>
 </td>
 <td>
   <span v-if="getOnlineStatus(user.last_online_at)" class="badge badge-success">Online</span>
   <span v-else class="badge badge-danger">Offline</span>
 </td>

methods: {
  ...someMethods,
 getOnlineStatus(testDate) {
                var myDate = new Date(testDate);
                var now = new Date();
                let FIVE_MINS = 60 * 5;
                return ((now - myDate) < FIVE_MINS);

            
            }
}
      


πŸ‘€bassxzero

Leave a comment