public function getProfileFullName($id) { $profile = UserProfile::find()->where(['id' => $id])->one(); if ($profile) { return $profile->first_name . ' ' . $profile->last_name; } }
public function actionMy() { if (\yii::$app->user->can('UserAccountMy')) { $account = User::findIdentity(\Yii::$app->user->identity->id); $profile = UserProfile::find()->where(['id' => \Yii::$app->user->identity->id])->one(); // ::search(['id' => \Yii::$app->user->identity->id ]); return $this->render('my', ['account' => $account, 'profile' => $profile, 'roles' => \Yii::$app->authManager->getRolesByUser(\Yii::$app->user->identity->id), 'module' => $this->module]); } else { throw new \yii\web\NotAcceptableHttpException('No Permission to view my data '); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserProfile::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(['id' => $this->id, 'gender' => $this->gender, 'birth_date' => $this->birth_date, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name]); return $dataProvider; }
/** * Finds the UserProfile model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserProfile the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserProfile::findOne($id)) !== null) { return $model; } else { return null; //throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Find User Profile data * @param type $id * @return boolean */ protected function findModelProfile($id) { if (($model = UserProfile::findOne($id)) !== null) { return $model; } else { return false; } }