src/Models/Session.php
public function scopeUsersBySeconds(Builder $builder, $seconds = 60): Builder
    {
        return $builder->with(['user'])->where('last_activity', '>=', now()->subSeconds($seconds))->whereNotNull('user_id');
    }
public function scopeUsersBySeconds(Builder $builder, $seconds = 60): Builder
    {
        return $builder->with(['user'])->where('last_activity', '>=', now()->subSeconds($seconds))->whereNotNull('user_id');
    }
public function scopeUsersBySeconds ( Builder $ builder , $ seconds = 60 ) : Builder { return $ builder -> with ( [ 'user' ] ) -> where ( 'last_activity' , '>=' , now ( ) -> subSeconds ( $ seconds ) ) -> whereNotNull ( 'user_id' ) ; }
Constrain the query to retrieve only sessions of users who
have been active within the specified number of seconds.

@param \Illuminate\Database\Eloquent\Builder $builder
@param int                                   $seconds

@return \Illuminate\Database\Eloquent\Builder
Constrain the query to retrieve only sessions of users who have been active within the specified number of seconds .