/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MentorEntrepreneur::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(['mentor_id' => $this->mentor_id, 'entrepreneur_id' => $this->entrepreneur_id]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMentorEntrepreneurs()
 {
     return $this->hasMany(MentorEntrepreneur::className(), ['entrepreneur_id' => 'id']);
 }
 /**
  * Finds the MentorEntrepreneur model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $mentor_id
  * @param integer $entrepreneur_id
  * @return MentorEntrepreneur the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($mentor_id, $entrepreneur_user_id)
 {
     if (($model = MentorEntrepreneur::findOne(['mentor_id' => $mentor_id, 'entrepreneur_user_id' => $entrepreneur_user_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }