/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ProceduresRequired::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; }
/** * adds required procedures * @param array $arr * @return array */ protected static function prepareProcedures($arr, $sex, $age, $analysis = [], $blood = []) { $records = ProceduresRequired::find()->all(); foreach ($records as $record) { if (preg_match('/женщин/ui', $record->descr) && $sex == 'м' || preg_match('/40/', $record->descr) && preg_match('/лет/ui', $record->descr) && preg_match('/старше/ui', $record->descr) && $age < 40) { continue; } if (preg_match('/анализ/ui', $record->name)) { $analysis[] = $record->name; continue; } if (in_array($record->name, ['АСТ', 'АЛТ', 'Билирубин'])) { $blood[] = $record->name; continue; } $arr[] = $record->name; } $arr = array_unique($arr); sort($arr); $blood = array_unique($blood); $analysis = array_unique($analysis); if ($blood) { $arr[] = implode(', ', $blood); } foreach ($analysis as $analys) { $arr[] = $analys; } return $arr; }
/** * Finds the ProceduresRequired model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProceduresRequired the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProceduresRequired::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }