Ejemplo n.º 1
0
 public function searchWait($params)
 {
     $query = Friends::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;
     }
     $usename = Yii::$app->user->identity->username;
     $query->andFilterWhere(['like', 'userOne', $this->userOne])->andFilterWhere(['like', 'userTwo', $this->userTwo]);
     $query->andFilterWhere(['or', ['like', 'userOne', $usename], ['like', 'userTwo', $usename]])->andFilterWhere(['like', 'state', "wait"]);
     $query->andFilterWhere(['not like', 'userOne', $usename]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFriends0()
 {
     return $this->hasMany(Friends::className(), ['userOne' => 'username']);
 }
Ejemplo n.º 3
0
 /**
  * Finds the Friends model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $userOne
  * @param string $userTwo
  * @return Friends the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($userOne, $userTwo)
 {
     if (($model = Friends::findOne(['userOne' => $userOne, 'userTwo' => $userTwo])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }