public function actionIndex() { $currentPsychologistId = Yii::$app->user->id; $profile = $this->findModel($currentPsychologistId); $directions = new Directions(); $problems = new Problems(); $sentDiplomaRequest = Diplomas::findOne(['psychologist_id' => $currentPsychologistId]); if ($profile->load(Yii::$app->request->post())) { if ($profile->save()) { return $this->render('index', ['profileModel' => $profile, 'message' => 'Профиль успешно обновлён', 'psychologistDirections' => $directions->getPsychologistDirections($currentPsychologistId), 'psychologistProblems' => $problems->getPsychologistProblems($currentPsychologistId), 'sentDiplomaRequest' => $sentDiplomaRequest]); } } else { //$this->logo = $imagesModel->getProfilePhoto(); return $this->render('index', ['profileModel' => $profile, 'psychologistDirections' => $directions->getPsychologistDirections($currentPsychologistId), 'psychologistProblems' => $problems->getPsychologistProblems($currentPsychologistId), 'sentDiplomaRequest' => $sentDiplomaRequest]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Problems::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, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Finds the Problems model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Problems the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Problems::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getAllProblems() { return Problems::find()->all(); }