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