/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Benefit::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->joinWith('benefitScholar'); $query->andFilterWhere([ 'benefit_id' => $this->benefit_id, 'benefit_amount' => $this->benefit_amount, 'benefit_scholarShare' => $this->benefit_scholarShare, 'benefit_tuitionfee_id' => $this->benefit_tuitionfee_id, 'benefit_scholar_id' => $this->benefit_scholar_id, 'benefit_school_id' => $this->benefit_school_id, ]); $query->andFilterWhere(['like', 'scholars.scholar_lastName', $this->benefit_scholar_lastName]) ->andFilterWhere(['like', 'scholars.scholar_firstName', $this->benefit_scholar_firstName]) ->andFilterWhere(['like', 'scholars.scholar_middleName', $this->benefit_scholar_middleName]); return $dataProvider; }
/** * Lists all Allowance models. * @return mixed */ public function actionIndex() { $schools = Schools::find()->all(); $users = User::find()->all(); $scholars = Scholars::find()->all(); $allowances = Allowance::find()->all(); $benefits = Benefit::find()->all(); return $this->render('index', array('users' => $users, 'scholars' => $scholars, 'schools' => $schools, 'allowances' => $allowances, 'benefits' => $benefits)); }
/** * @return \yii\db\ActiveQuery */ public function getBenefits() { return $this->hasMany(Benefit::className(), ['benefit_scholar_id' => 'scholar_id']); }
/** * Finds the Benefit model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Benefit the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Benefit::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getBenefitAllowance() { return $this->hasOne(Benefit::className(), ['benefit_id' => 'benefit_allowance_id']); }