/** * Finds user by [[username]] * * @return User|null */ public function getUser() { if ($this->_user === false) { $this->_user = User::findByUsername($this->username); } return $this->_user; }
/** * Searches users. * @param array $params search query data * @return ActiveDataProvider */ public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['status' => $this->status])->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(updated_at), "%Y-%m-%d")', $this->updated_at]); return $dataProvider; }
public function install() { \app\config\ConfigManager::set(['components', 'user', 'identityClass'], User::className()); }
/** * @return \yii\db\ActiveQuery */ public function getUser() { return self::hasOne(User::className(), ['id' => 'user_id']); }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @param bool $search * @return User|UserSearch the loaded model * @throws NotFoundHttpException */ protected function findModel($id, $search = false) { if ($search) { $model = new UserSearch(); } elseif (!$id) { $model = new User(); } elseif (!($model = User::findOne($id))) { throw new NotFoundHttpException(\Yii::t('modules/user', 'User not found')); } $model->scenario = 'root'; return $model; }
public function down() { $this->dropTable(User::tableName()); }