public function CheckEmailInBD($attribute) { $userObj = user::find()->where(['email' => $this->{$attribute}])->one(); if ($userObj !== null) { $this->addError($attribute, 'email all ready taken'); } }
/** * 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, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * 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, 'online' => $this->online]); $query->andFilterWhere(['or', ['like', 'first_name', $this->userFullName], ['like', 'last_name', $this->userFullName]])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['and', ['>=', '((UNIX_TIMESTAMP()-UNIX_TIMESTAMP(`bd_date`))/60/60/24/365)', $this->min_year], ['<=', '((UNIX_TIMESTAMP()-UNIX_TIMESTAMP(`bd_date`))/60/60/24/365)', $this->max_year]])->andFilterWhere(['like', 'country', $this->country]); return $dataProvider; }
public function editShow($id) { return view('userEditForm', user::find($id)); }
public function actionGetUserRef() { $users = user::find()->orderBy('name ASC')->All(); foreach ($users as $user) { if ($user->active) { printf('<option value = %d>%s</option>', $user->id, $user->name); } else { printf('<option value = %d>%s (неактивен)</option>', $user->id, $user->name); } } }
/** * Lists all user models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => user::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }