/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = SpecialistsRequired::find();

        $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;
        }

        $query->andFilterWhere([
            'id' => $this->id,
        ]);

        $query->andFilterWhere(['ilike', 'name', $this->name]);
        $query->andFilterWhere(['ilike', 'descr', $this->descr]);

        return $dataProvider;
    }
Пример #2
0
 /**
  * adds required specialists
  * @param array $arr
  * @return array
  */
 protected static function prepareSpecialists($arr, $sex = false)
 {
     $records = SpecialistsRequired::find()->all();
     $ophtalmologist = false;
     $neurologist = false;
     foreach ($records as $record) {
         if ($sex && preg_match('/женщин/ui', $record->descr) && $sex == 'м' || preg_match('/(нарколог|психиатр)/ui', $record->name)) {
             continue;
         }
         if (preg_match('/(офтальмолог|окулист)/ui', $record->name)) {
             $ophtalmologist = $record->name;
         }
         if (preg_match('/(невролог)/ui', $record->name)) {
             $neurologist = $record->name;
         }
         $arr[] = $record->name;
     }
     $arr = array_unique($arr);
     sort($arr);
     if ($ophtalmologist) {
         $arr[] = $ophtalmologist;
     }
     if ($neurologist) {
         $arr[] = $neurologist;
     }
     $arr[] = 'Нарколог';
     $arr[] = 'Психиатр';
     return $arr;
 }
 /**
  * Finds the SpecialistsRequired model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SpecialistsRequired the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SpecialistsRequired::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }