/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TblAssetLoan::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['entry_id' => SORT_DESC]]]); $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('externalUser'); $query->joinWith('statuS'); $query->andFilterWhere(['entry_id' => $this->entry_id, 'form_id' => $this->form_id, 'user_id' => $this->user_id, 'form_type' => $this->form_type, 'closed_by' => $this->closed_by, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'update_date' => $this->update_date, 'assigned_to' => $this->assigned_to, 'expected_return' => $this->expected_return, 'loan_date' => $this->loan_date]); $query->andFilterWhere(['like', 'inventory', $this->inventory])->andFilterWhere(['like', 'purpose', $this->purpose])->andFilterWhere(['like', 'purpose_other', $this->purpose_other])->andFilterWhere(['like', 'comments', $this->comments])->andFilterWhere(['or', ['like', 'tbl_external_user.first_name', $this->external_user], ['like', 'tbl_external_user.last_name', $this->external_user]])->andFilterWhere(['like', 'tbl_statuses.status_name', $this->status]); return $dataProvider; }
/** * Finds the TblAssetLoan model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TblAssetLoan the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TblAssetLoan::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }