Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $id = Yii::$app->user->identity->getId();
     $query = Frendpovod::find()->leftJoin('`frends` as `f`', '`f`.`id`=`frend_id`')->leftJoin('`otk_povod` as `p`', '`p`.`id`=`povod_id`')->where('user_id=:user_id', ['user_id' => $id]);
     $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, 'frendname' => $this->frendname, 'povodname' => $this->povodname]);
     $dataProvider->setSort(['attributes' => ['date' => ['asc' => ['month' => SORT_ASC, 'days' => SORT_ASC], 'desc' => ['month' => SORT_DESC, 'days' => SORT_DESC], 'default' => SORT_ASC]]]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Finds the Frendpovod model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Frendpovod the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Frendpovod::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 public function getFrendPovod()
 {
     return $this->hasMany(Frendpovod::className(), ['povod_id' => 'id'])->viaTable('frends', ['id' => 'frend_id'])->groupBy('email');
 }