/** * Displays a single Friends model. * @param string $userOne * @param string $userTwo * @return mixed */ public function actionView($user) { $model = User::find()->where('username = :username', [':username' => $user])->one(); $owner_id = $model["id"]; $dataProvider = new ActiveDataProvider(['query' => Album::find()->where(['owner_id' => '' . $owner_id, 'shareable' => '1'])]); $query = new Query(); $dataProviderOne = new ActiveDataProvider(['query' => $query->select("*")->from('album')->innerJoin('yetki', 'yetki.id' . '=' . 'album.id')->where('owner_id = ' . $owner_id)]); return $this->render('view', ['dataProvider' => $dataProvider, 'dataProviderOne' => $dataProviderOne]); }
/** * 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 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', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->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]); $usename = Yii::$app->user->identity->username; $tempQuery = new \yii\data\SqlDataProvider(['sql' => "select * from friends where userOne='{$usename}' or userTwo='{$usename}'"]); $veriler = $tempQuery->getModels(); foreach ($veriler as $row) { $query->andFilterWhere(['not like', 'username', $row["userOne"]]); $query->andFilterWhere(['not like', 'username', $row["userTwo"]]); } return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getUserOne0() { return $this->hasOne(User::className(), ['username' => 'userOne']); }
/** * 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 = User::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getOwner() { return $this->hasOne(User::className(), ['id' => 'owner_id']); }