Get count of users group by group and date , laravel

Viewed 32

I have a subscriber table where every subscriber belongs to one group, which I identified by this relation

public function group(){
    return $this->belongsTo('App\Models\Ispgroup','id','group_id');
}

and I have another table that collects the logs for every subscriber, like the time that user gets online and the time when the subscriber gets disconnected, and I identified this relationship depending on the username like this

public function logs() {
    return $this->hasMany('App\Models\Logs', 'username', 'username');
}

Logs table has this structure,

username ------- online_at(DateTime) --------- disconnected_at(DateTime)

I want to get the count of online users for the last hour group by group and by minutes, as I'll show the graph in minutes

0 Answers
Related