コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::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;
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (Yii::$app->user->identity->type == 'admin') {
         $query = Users::find();
     } else {
         if (Yii::$app->user->identity->type == 'partner') {
             $query = Users::find()->where(['partner_id' => Yii::$app->user->identity->id, 'status' => 10])->orWhere(['id' => Yii::$app->user->identity->id, 'status' => 10]);
         } else {
             if (Yii::$app->user->identity->type == 'client') {
                 $query = Users::find()->where(['id' => Yii::$app->user->identity->id, 'status' => 10]);
             }
         }
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC, 'updated_at' => SORT_DESC, 'name' => SORT_ASC]]]);
     if ($this->load($params) && !$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'partner_id' => $this->partner_id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'partner_id', $this->partner_id])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: LoginDetails.php プロジェクト: aekkapun/dlt-tcplch
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLoginUser()
 {
     return $this->hasOne(Users::className(), ['user_id' => 'login_user_id']);
 }
コード例 #4
0
 /**
  * Finds the Users model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Users the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (Yii::$app->user->identity->type == 'admin') {
         $model = Users::findOne($id);
     } else {
         if (Yii::$app->user->identity->type == 'partner') {
             $model = Users::find()->where('id = :id AND id = :partner_id AND type != :type', [':id' => $id, ':partner_id' => $id, ':type' => 'admin'])->one();
         } else {
             if (Yii::$app->user->identity->type == 'client') {
                 $model = Users::findOne(['id' => Yii::$app->user->identity->id, 'status' => 10]);
             }
         }
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: UsersController.php プロジェクト: TrickTrick/board
 public function actionIndex()
 {
     $users = Users::find()->all();
     return $this->render('index', ['model' => $users]);
 }
コード例 #6
0
 /**
  * Finds the Users model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Users the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Users::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }