Exemplo n.º 1
0
 public function actionPhoto()
 {
     $request = \Yii::$app->request;
     $model = new Search();
     $photos = 1;
     if ($model->load(\Yii::$app->request->get()) && isset($model['name'])) {
         $contentId = $request->post('contentId');
         if ($model->marks != "") {
             $marks = Search::getMarksArray($model->marks);
         }
         $photos = Search::searchPhoto($model['name'], $model['id_level_1'], $model['id_level_2'], $marks, 20, $contentId);
     }
     if ($request->isAjax) {
         return json_encode(['content' => $photos]);
     }
     $all_categories = Category::getAllTranslatedCategory();
     $all_subcategories = Category::getAllTranslatedSubCategory();
     return $this->render('photo', ['model' => $model, 'photos' => $photos, 'all_categories' => $all_categories, 'all_subcategories' => $all_subcategories]);
 }