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.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							657 B
						
					
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							657 B
						
					
					
				| <?php | |
|  | |
| namespace core\entities\post\queries; | |
|  | |
| use core\entities\post\Post; | |
| use yii\db\ActiveQuery; | |
|  | |
| class PostQuery extends ActiveQuery | |
| { | |
|     /** | |
|      * @param null $alias | |
|      * @return $this | |
|      */ | |
|     public function active($alias = null) | |
|     { | |
|         return $this->andWhere([ | |
|             ($alias ? $alias . '.' : '') . 'status' => Post::STATUS_ACTIVE, | |
|         ]); | |
|     } | |
|  | |
|     public function byType($type) | |
|     { | |
|     	return $this->andWhere(['type_id' => $type]); | |
|     } | |
|  | |
|     public function last() | |
|     { | |
|     	return $this->orderBy(['published_at' => SORT_DESC]); | |
|     } | |
|  | |
| 	public function popular() | |
| 	{ | |
| 		return $this->orderBy(['views' => SORT_DESC]); | |
| 	} | |
| } |