/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Optionalwork::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('scholarScholar'); $query->andFilterWhere(['optionalwork_id' => $this->optionalwork_id, 'scholar_scholar_id' => $this->scholar_scholar_id, 'scholar_school_school_id' => $this->scholar_school_school_id, 'optionalwork_start_date' => $this->optionalwork_start_date, 'optionalwork_end_date' => $this->optionalwork_end_date]); $query->andFilterWhere(['like', 'optionalwork_location', $this->optionalwork_location])->andFilterWhere(['like', 'optional_work_company_name', $this->optional_work_company_name])->andFilterWhere(['like', 'scholar.scholar_first_name', $this->firstName])->andFilterWhere(['like', 'scholar.scholar_middle_name', $this->middleName])->andFilterWhere(['like', 'scholar.scholar_last_name', $this->lastName]); return $dataProvider; }
/** * Finds the Optionalwork model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $optionalwork_id * @param integer $scholar_scholar_id * @param integer $scholar_school_school_id * @return Optionalwork the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Optionalwork::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getOptionalworks0() { return $this->hasMany(Optionalwork::className(), ['scholar_school_school_id' => 'school_school_id']); }