/**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Admin::findByUsername($this->username);
     }
     return $this->_user;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Admin::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => Yii::$app->params['defaultPageSize'], 'pageParam' => 'page']]);
     $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->where("status != -1");
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'role' => $this->role, 'modtime' => $this->modtime, 'createtime' => $this->createtime]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'name', $this->name]);
     if ($this->keyword) {
         $query->andWhere("username LIKE :keyword OR name LIKE :keyword")->addParams([":keyword" => "%{$this->keyword}%"]);
     }
     return $dataProvider;
 }
 /**
  * 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)
 {
     if (($model = Admin::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.', $this->errorLayout);
     }
 }