app/Models/User.php
/**
     * Scope a query to get online users
     *
     * @param Builder $query
     * @return Builder
     */
Scope a query to get online users
@param Builder $query
@return Builder
Scope a query to get online users @param Builder $query @return Builder
public function scopeOnline($query)
    {
        if (auth()->id()) {
            $query->where('users.id', '!=', auth()->id());
        }
        return $query->where(
            'users.last_online',
            '>',
            Carbon::now()->subMinutes($this->onlineMinutes)->toDateTimeString()
        );
    }
public function scopeOnline ( $ query ) { if ( auth ( ) -> id ( ) ) { $ query -> where ( 'users.id' , '!=' , auth ( ) -> id ( ) ) ; } return $ query -> where ( 'users.last_online' , '>' , Carbon :: now ( ) -> subMinutes ( $ this -> onlineMinutes ) -> toDateTimeString ( ) ) ; }
Scope a query to get online users
 @param Builder $query
 @return Builder
Scope a query to get online users @param Builder $query @return Builder
// Skip authenticated user