/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = StrukturnoePodrazdelenie::find();
     $query->joinWith(['organizaciya0']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['nazvanie', 'sokrashennoe_nazvanie', 'obschij', 'organizaciyaNazvanie' => ['asc' => ['organizaciya.nazvanie' => SORT_ASC], 'desc' => ['organizaciya.nazvanie' => SORT_DESC], 'label' => 'Организация']]]);
     $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;
     }
     $query->andFilterWhere(['strukturnoe_podrazdelenie.obschij' => $this->obschij]);
     $query->andFilterWhere(['like', 'strukturnoe_podrazdelenie.nazvanie', $this->nazvanie])->andFilterWhere(['like', 'strukturnoe_podrazdelenie.sokrashennoe_nazvanie', $this->sokrashennoe_nazvanie])->andFilterWhere(['like', 'organizaciya.nazvanie', $this->organizaciyaNazvanie]);
     return $dataProvider;
 }
 /**
  * Finds the StrukturnoePodrazdelenie model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return StrukturnoePodrazdelenie the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = StrukturnoePodrazdelenie::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }