src/Kim/Activity/Traits/ActivitySorter.php
public function scopeOrderByUsers($query, $column, $dir = 'ASC')
    {
        $table = $this->getTable();

        $userModel = config('auth.providers.users.model');
        $user = new $userModel;
        $userTable = $user->getTable();
        $userKey = $user->getKeyName();

        return $query->join($userTable, "{$table}.user_id", '=', "{$userTable}.{$userKey}")->orderBy("{$userTable}.{$column}", $dir);
    }
public function scopeOrderByUsers($query, $column, $dir = 'ASC')
    {
        $table = $this->getTable();

        $userModel = config('auth.providers.users.model');
        $user = new $userModel;
        $userTable = $user->getTable();
        $userKey = $user->getKeyName();

        return $query->join($userTable, "{$table}.user_id", '=', "{$userTable}.{$userKey}")->orderBy("{$userTable}.{$column}", $dir);
    }
public function scopeOrderByUsers ( $ query , $ column , $ dir = 'ASC' ) { $ table = $ this -> getTable ( ) ; $ userModel = config ( 'auth.providers.users.model' ) ; $ user = new $ userModel ; $ userTable = $ user -> getTable ( ) ; $ userKey = $ user -> getKeyName ( ) ; return $ query -> join ( $ userTable , "{$table}.user_id" , '=' , "{$userTable}.{$userKey}" ) -> orderBy ( "{$userTable}.{$column}" , $ dir ) ; }
Use joins to order by the users' column attributes.

@param  \Illuminate\Database\Query\Builder  $query
@param  string  $column
@return \Illuminate\Database\Query\Builder|static
Use joins to order by the users column attributes .