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.
29 lines
555 B
29 lines
555 B
<?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 |
|
{ |
|
public int $count; |
|
|
|
public function __construct( array $config = [] ) { |
|
parent::__construct( $config ); |
|
$this->count = $this->count ?: 3; |
|
} |
|
|
|
public function run(): string |
|
{ |
|
$comments = PostComment::find()->orderBy(['created_at' => SORT_DESC])->limit($this->count)->all(); |
|
|
|
return $this->render('comments', [ |
|
'comments' => $comments, |
|
]); |
|
} |
|
}
|
|
|