/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Reference::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('createdBy')->andFilterWhere(['reference.create_date' => $this->create_date])->andFilterWhere(['like', 'reference_name', $this->reference_name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'reference.status', $this->status])->andFilterWhere(['like', 'CONCAT(full_name,username)', $this->created_by]); return $dataProvider; }
/** * Finds the Reference model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Reference the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Reference::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getReference() { return $this->hasOne(Reference::className(), ['id' => 'reference_id']); }