public function search($params)
 {
     $query = StudentAddress::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'student_id' => $this->student_id, 'ord' => $this->ord, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'line1', $this->line1])->andFilterWhere(['like', 'line2', $this->line2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state_abbr', $this->state_abbr])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * @return \app\Models\StudentAddress
  */
 public function getBestAddress()
 {
     return StudentAddress::find()->joinWith('student')->where(['student.id' => $this->id])->orderBy(['student_address.ord' => SORT_ASC])->one();
 }
 /**
  * Finds the StudentAddress model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return StudentAddress the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = StudentAddress::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }