Skip to content

Commit

Permalink
fix getAuthors function
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Jan 13, 2017
1 parent 67d9aaf commit ed3f0a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions models/CommentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function getAvatar()
return $this->author->getAvatar();
}

return 'http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y&s=50';
return 'http://www.gravatar.com/avatar?d=mm&f=y&s=50';
}

/**
Expand All @@ -337,7 +337,15 @@ public function getAvatar()
*/
public static function getAuthors()
{
return ArrayHelper::map(static::find()->joinWith('author')->groupBy('createdBy')->asArray()->all(), 'createdBy', 'author.username');
$query = static::find()
->alias('c')
->select(['c.createdBy', 'a.username'])
->joinWith('author a')
->groupBy('c.createdBy')
->asArray()
->all();

return ArrayHelper::map($query, 'createdBy', 'author.username');
}

/**
Expand Down

0 comments on commit ed3f0a2

Please sign in to comment.