本文整理汇总了PHP中app\modules\user\models\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\modules\user\models\User
的用法示例。
在下文中一共展示了User::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* Finds user by id.
*
* @return User|null User instance
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::find()->where(['id' => Yii::$app->user->identity->id])->active()->one();
}
return $this->_user;
}
示例2: getUsersFoundCod
protected function getUsersFoundCod()
{
$user = User::find()->where(['cod' => $this->codUser])->one();
if (isset($user)) {
return $user->id;
} else {
return 0;
}
}
示例3: search
/**
* 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(['like', 'id', $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->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;
}
示例4: search
/**
* 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, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'FROM_UNIXTIME(created_at, "%d.%m.%Y")' => $this->created_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', 'role', $this->role])->andFilterWhere(['like', 'email', $this->email]);
return $dataProvider;
}
示例5: actionAjaxUser
/**
* @return array
*/
public function actionAjaxUser()
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$result = ['more' => false, 'results' => []];
$search = \Yii::$app->request->get('search', []);
if (!empty($search['term'])) {
$query = User::find()->select('id, username, first_name, email')->where(['like', 'username', trim($search['term'])])->orWhere(['like', 'email', trim($search['term'])])->orWhere(['like', 'first_name', trim($search['term'])])->asArray();
$result['results'] = array_values($query->all());
}
return $result;
}
示例6: search
/**
* 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]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'followers' => $this->followers, 'following' => $this->following, 'photos' => $this->photos, 'avatar_sid' => $this->avatar_sid, 'status' => $this->status, 'last_visit_at' => $this->last_visit_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'email', $this->email])->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', 'last_login_ip', $this->last_login_ip]);
return $dataProvider;
}
示例7: actionRemoveOverdue
public function actionRemoveOverdue()
{
foreach (User::find()->overdue($this->module->emailConfirmUserExpire)->each() as $user) {
/** @var User $user */
$this->stdout($user->username . ' - ' . $user->email);
$user->delete();
$this->stdout('OK', Console::FG_GREEN, Console::BOLD);
$this->stdout(PHP_EOL);
}
$this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
$this->stdout(PHP_EOL);
}
示例8: actionRemoveOverdue
/**
* Removes non-activated expired users
*/
public function actionRemoveOverdue()
{
foreach (User::find()->overdue(Yii::$app->params['user.emailConfirmUserExpire'])->each() as $user) {
/** @var User $user */
$this->stdout($user->username);
$user->delete();
$this->stdout(' OK', Console::FG_GREEN, Console::BOLD);
$this->stdout(PHP_EOL);
}
$this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
$this->stdout(PHP_EOL);
}
示例9: findModel
/**
* 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
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (is_numeric($id)) {
$model = User::findOne($id);
} else {
$model = User::find()->where(['username' => $id])->one();
}
if ($model !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例10: search
/**
* 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 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', 'email', $this->email])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token]);
return $dataProvider;
}
示例11: search
/**
* 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 any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'marital' => $this->marital, 'birthday' => $this->birthday, 'post_id' => $this->post_id, 'department_id' => $this->department_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'visited_at' => $this->visited_at, 'views' => $this->views, 'weight' => $this->weight, 'status_id' => $this->status_id]);
$query->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'patronymic', $this->patronymic])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'token', $this->token])->andFilterWhere(['like', 'email_confirm_token', $this->email_confirm_token])->andFilterWhere(['like', 'phone_work', $this->phone_work])->andFilterWhere(['like', 'phone_private', $this->phone_private])->andFilterWhere(['like', 'email_work', $this->email_work])->andFilterWhere(['like', 'email_private', $this->email_private]);
return $dataProvider;
}
示例12: search
/**
* 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, 'sort' => false]);
$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(['status' => $this->status]);
$query->andFilterWhere(['like', 'email', $this->email]);
$query->andFilterWhere(['like', 'username', $this->username]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
$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;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
$query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['>=', 'created_at', $this->created_at ? strtotime($this->created_at . ' 00:00:00') : null])->andFilterWhere(['<=', 'created_at', $this->created_at ? strtotime($this->created_at . ' 23:59:59') : null]);
return $dataProvider;
}
示例14: actionRemoveOverdue
/**
* Removes non-activated expired users
*/
public function actionRemoveOverdue()
{
foreach (User::find()->overdue($this->module->emailConfirmTokenExpire)->each() as $user) {
/** @var User $user */
$this->stdout($user->username);
if ($user->delete()) {
Yii::info('Remove expired user ' . $user->username);
$this->stdout(' OK', Console::FG_GREEN, Console::BOLD);
} else {
Yii::warning('Cannot remove expired user ' . $user->username);
$this->stderr(' FAIL', Console::FG_RED, Console::BOLD);
}
$this->stdout(PHP_EOL);
}
$this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
$this->stdout(PHP_EOL);
}
示例15:
/*$listdata = ArrayHelper::map(Post::find()->all(), 'id', 'title'); ?>
<?= $form->field($model, 'post_id')->dropDownList($listdata, [
'class' => 'form-control select',
'prompt' => Yii::t('app', 'Select from list')
]); */
?>
<?php
$listdata = ArrayHelper::map(Department::find()->all(), 'id', 'title');
?>
<?php
echo $form->field($model, 'department_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>
<?php
$listdata = ArrayHelper::map(User::find()->all(), 'id', 'last_name');
?>
<?php
echo $form->field($model, 'user_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>
<?php
$listdata = ArrayHelper::map(Address::find()->all(), 'id', 'title');
?>
<?php
echo $form->field($model, 'address_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>
<?php
echo $form->field($model, 'place_id')->widget(DepDrop::classname(), ['options' => ['id' => 'place_id'], 'pluginOptions' => ['depends' => ['user-address_id'], 'placeholder' => 'Select...', 'url' => Url::to(['/place/list'])]]);