Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. public function actionSearch($q){
  2.         if(strstr($q,"tag:")){
  3.             $tag = explode(":",$q)[1];
  4.         }
  5.         $tags = null;
  6.  
  7.  
  8.         $models = \common\models\Pages::find()
  9.             ->where(['like','title',$q])
  10.             ->orWhere(['like','description',$q])
  11.             ->all();
  12.  
  13.         if(isset($tag)){
  14.             $tags = \common\models\eProductsTags::find()->where(['tag' => $tag])->all();
  15.         }
  16.  
  17.            
  18.         return $this->render('search',['models'=>$models,'q'=>$q,'tags'=>$tags]);
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement