You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
555 B

7 years ago
<?php
/**
* Created by Error202
* Date: 10.02.2018
*/
namespace frontend\widgets\post;
use core\entities\post\PostComment;
use yii\base\Widget;
class LastCommentsWidget extends Widget
{
3 years ago
public int $count;
7 years ago
public function __construct( array $config = [] ) {
parent::__construct( $config );
3 years ago
$this->count = $this->count ?: 3;
7 years ago
}
3 years ago
public function run(): string
{
7 years ago
$comments = PostComment::find()->orderBy(['created_at' => SORT_DESC])->limit($this->count)->all();
return $this->render('comments', [
'comments' => $comments,
]);
}
3 years ago
}