Skip to content

Commit ed3f0a2

Browse files
author
igor-chepurnoi
committed
fix getAuthors function
1 parent 67d9aaf commit ed3f0a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

models/CommentModel.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function getAvatar()
327327
return $this->author->getAvatar();
328328
}
329329

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

333333
/**
@@ -337,7 +337,15 @@ public function getAvatar()
337337
*/
338338
public static function getAuthors()
339339
{
340-
return ArrayHelper::map(static::find()->joinWith('author')->groupBy('createdBy')->asArray()->all(), 'createdBy', 'author.username');
340+
$query = static::find()
341+
->alias('c')
342+
->select(['c.createdBy', 'a.username'])
343+
->joinWith('author a')
344+
->groupBy('c.createdBy')
345+
->asArray()
346+
->all();
347+
348+
return ArrayHelper::map($query, 'createdBy', 'author.username');
341349
}
342350

343351
/**

0 commit comments

Comments
 (0)