Cronix
Cronix
1 month ago (783,370 XP)

Ah, yeah I wouldn't do that. It's not accurate. If you really need to, I'd add an additional constraint to your query.

$users = Session::whereNotNull('user_id')
    ->where('last_activity', '>=', now()->subMinutes(10)) // active in last 10 minutes
    ->get();
anonymouse703

Yeah sir that's now what I implemented.. but I missed subMinutes(10)

   $users = Session::where('last_active_at', '>=', now()->subMinute())->whereNotNull('user_id')->get();

Thanks again sir.. I need now to make a cron job to refresh my connection monitoring view every 5 mins.

anonymouse703

sir @Cronix is this right? I need to refresh the table in a div (#monitoring)

   (function () {
    setInterval(function () {
        axios.get('pages.admin.system.connection-monitoring.index',)
            .then(function(response){
                    document.querySelector('#monitoring')
                            .innerHtml(response.data);
            }); // do nothing for error - leaving old content.
        }); 
    }, 300 000); // mi  

Please sign in or create an account to participate in this conversation.