public function search($params) { $query = Profile::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['id', 'first_name', 'last_name', 'birthdate', 'genderName' => ['asc' => ['gender.gender_name' => SORT_ASC], 'desc' => ['gender.gender_name' => SORT_DESC], 'label' => 'Gender'], 'profileIdLink' => ['asc' => ['profile.id' => SORT_ASC], 'desc' => ['profile.id' => SORT_DESC], 'label' => 'ID'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User']]]); if (!($this->load($params) && $this->validate())) { $query->joinWith(['gender'])->joinWith(['user']); return $dataProvider; } $this->addSearchParameter($query, 'id'); $this->addSearchParameter($query, 'first_name', true); $this->addSearchParameter($query, 'last_name', true); $this->addSearchParameter($query, 'birthdate'); $this->addSearchParameter($query, 'gender_id'); $this->addSearchParameter($query, 'created_at'); $this->addSearchParameter($query, 'updated_at'); $this->addSearchParameter($query, 'user_id'); // filter by gender name $query->joinWith(['gender' => function ($q) { $q->andFilterWhere(['=', 'gender.gender_name', $this->genderName]); }])->joinWith(['user' => function ($q) { $q->andFilterWhere(['=', 'user.id', $this->user]); }]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Profile::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(['like', '_id', $this->_id])->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'dob', $this->dob])->andFilterWhere(['like', 'age', $this->age])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'addressLine1', $this->addressLine1])->andFilterWhere(['like', 'addressLine2', $this->addressLine2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'zipCode', $this->zipCode])->andFilterWhere(['like', 'telNumber', $this->telNumber])->andFilterWhere(['like', 'faxNumber', $this->faxNumber])->andFilterWhere(['like', 'mobileNumber', $this->mobileNumber])->andFilterWhere(['like', 'profilePics', $this->profilePics])->andFilterWhere(['like', 'drRegNo', $this->drRegNo])->andFilterWhere(['like', 'drSpecialist', $this->drSpecialist])->andFilterWhere(['like', 'drHospital', $this->drHospital])->andFilterWhere(['like', 'drDesignation', $this->drDesignation])->andFilterWhere(['like', 'workLocation', $this->workLocation])->andFilterWhere(['like', 'qualification', $this->qualification])->andFilterWhere(['like', 'university', $this->university])->andFilterWhere(['like', 'totExp', $this->totExp])->andFilterWhere(['like', 'profileSummary', $this->profileSummary])->andFilterWhere(['like', 'paDisease', $this->paDisease])->andFilterWhere(['like', 'paSubDisease', $this->paSubDisease])->andFilterWhere(['like', 'repProdName', $this->repProdName])->andFilterWhere(['like', 'repCompName', $this->repCompName])->andFilterWhere(['like', 'repTot', $this->repTot])->andFilterWhere(['like', 'userId', $this->userId]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Profile::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, 'user_id' => $this->user_id, 'birthdate' => $this->birthdate, 'gender_id' => $this->gender_id, 'created_at' => $this->created_at, 'updatead_at' => $this->updatead_at]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Profile::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['profileID' => $this->profileID, 'userID' => $this->userID]); $query->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'middleName', $this->middleName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'gender', $this->gender]); return $dataProvider; }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { $currentUserId = (string) Yii::$app->user->identity->_id; $currProfile = Profile::find()->where(['userId' => new \MongoId($currentUserId)])->asArray()->all(); $session = Yii::$app->session; $session['profile'] = $currProfile; return $this->goBack(); } else { return $this->render('login', ['model' => $model]); } }
public function actionIndex() { $name = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one(); return $this->render('index', ['name' => $name]); }
/** * Deletes an existing Profile model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = Profile::find()->where(['user_id' => Yii::$app->user->identity->id])->one(); $this->findModel($model->id)->delete(); return $this->redirect(['site/index']); }
public function actionSearchdoc() { $model = new SearchdocForm(); $user_ids = array(); $prof = new Profile(); if (Yii::$app->request->post()) { $location = $_POST['SearchdocForm']['location']; $drSpecialist = $_POST['SearchdocForm']['drSpecialist']; $model->location = $location; $model->drSpecialist = $drSpecialist; if ($location != "" && $drSpecialist != "") { $matched_id = ArrayHelper::map(Profile::find()->where(['drSpecialist' => new \MongoId($drSpecialist), 'city' => (string) $location])->all(), function ($prof) { return $prof->userId->{'$id'}; }, 'city'); foreach ($matched_id as $key => $value) { array_push($user_ids, $key); } } elseif ($location != "") { $matched_id = ArrayHelper::map(Profile::find()->where(['city' => (string) $location])->all(), function ($prof) { return $prof->userId->{'$id'}; }, 'city'); foreach ($matched_id as $key => $value) { array_push($user_ids, $key); } } elseif ($drSpecialist != "") { $matched_id = ArrayHelper::map(Profile::find()->where(['drSpecialist' => new \MongoId($drSpecialist)])->all(), function ($prof) { return $prof->userId->{'$id'}; }, 'city'); foreach ($matched_id as $key => $value) { array_push($user_ids, $key); } } else { } $doctors = User::find()->where(['_id' => $user_ids, "user_role" => '1'])->with('profile')->all(); } else { $currentUserId = Yii::$app->user->identity->_id; $session = Yii::$app->session; $location = Yii::$app->session['profile'][0]['city']; $model->location = $location; $matched_id = ArrayHelper::map(Profile::find()->where(['city' => (string) $location])->all(), function ($prof) { return $prof->userId->{'$id'}; }, 'city'); foreach ($matched_id as $key => $value) { array_push($user_ids, $key); } $doctors = User::find()->where(['_id' => $user_ids, "user_role" => '1'])->with('profile')->all(); } return $this->render('searchdoc', ['model' => $model, 'doctors' => $doctors]); }