/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CsTags::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'entity_id' => $this->entity_id]); $query->andFilterWhere(['like', 'entity', $this->entity])->andFilterWhere(['like', 'lang_code', $this->lang_code])->andFilterWhere(['like', 'tag', $this->tag])->andFilterWhere(['like', 'orig_name', $this->orig_name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getTags() { $tags = CsTags::find()->where('lang_code="SR" and entity_id=' . $this->id . ' and entity="object"')->all(); return $tags ? $tags : false; }
/** * Lists all CsServices models. * @return mixed */ public function actionIndex() { $request = Yii::$app->request; $post = $request->post('CsServicesSearch'); // industry if (isset($post['industry_id']) && $post['industry_id'] != null && $post['industry_id'] != '') { $industry = CsIndustries::findOne($post['industry_id']); return $this->redirect(['/services/i/' . slug($industry->tName)]); } // object if (isset($post['object_id']) && $post['object_id'] != null && $post['object_id'] != '') { $object = CsObjects::findOne($post['object_id']); return $this->redirect(['/services/o/' . slug($object->tName)]); } // product if (isset($post['product_id']) && $post['product_id'] != null && $post['product_id'] != '') { $product = CsProducts::findOne($post['product_id']); return $this->redirect(['/services/p/' . slug($product->name)]); } // action if (isset($post['action_id']) && $post['action_id'] != null && $post['action_id'] != '') { $action = CsActions::findOne($post['action_id']); return $this->redirect(['/services/a/' . slug($action->tName)]); } // service if (isset($post['id']) && $post['id'] != null && $post['id'] != '') { $service = CsServices::findOne($post['id']); return $this->redirect(['/s/' . slug($service->tName)]); } // tags if (isset($post['tag_id']) && $post['tag_id'] != null && $post['tag_id'] != '') { $tag = CsTags::findOne($post['tag_id']); switch ($tag->entity) { case 'action': return $this->redirect(['/services', 'a' => $tag->entity_id]); break; case 'object': return $this->redirect(['/services', 'o' => $tag->entity_id]); break; case 'industry': return $this->redirect(['/services', 'i' => $tag->entity_id]); break; case 'service': $service = CsServices::findOne($tag->entity_id); return $this->redirect(['/s/' . slug($service->tName)]); break; default: return $this->redirect(['/services']); break; } } if (isset($post['name']) && $post['name'] != null && $post['name'] != '') { return $this->redirect(['/services', 'q' => $post['name']]); } }
/** * @return \yii\db\ActiveQuery */ public function getTags() { return $this->hasMany(CsTags::className(), ['lang_code' => 'code']); }
/** * Finds the CsTags model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return CsTags the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CsTags::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }