/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel() { $id = Yii::$app->user->identity['id']; if (($model = User::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = User::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, 'u_status' => $this->u_status, 'u_time_link' => $this->u_time_link, 'date_post' => $this->date_post, 'update_post' => $this->update_post]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'u_snp', $this->u_snp])->andFilterWhere(['like', 'u_company', $this->u_company])->andFilterWhere(['like', 'u_activation_link', $this->u_activation_link]); return $dataProvider; }
public function bla() { //$password = '******'; $password = User::find()->where(['id' => Yii::$app->user->identity['id']])->one(); return $password->password; }
public function getAuthor() { return $this->hasOne(User::className(), ['id' => 'id_user']); }