/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Trips::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'date_of_travel' => $this->date_of_travel, 'vehicle_id' => $this->vehicle_id, 'driver_id' => $this->driver_id, 'material_id' => $this->material_id, 'measurement_type' => $this->measurement_type, 'vehicle_rent' => $this->vehicle_rent, 'driver_amount' => $this->driver_amount, 'merchant_amount' => $this->merchant_amount, 'buyer_amount' => $this->buyer_amount, 'buyer_amount_total' => $this->buyer_amount_total]); $query->andFilterWhere(['like', 'size', $this->size])->andFilterWhere(['like', 'site_name', $this->site_name])->andFilterWhere(['like', 'site_place', $this->site_place])->andFilterWhere(['like', 'kilometre', $this->kilometre])->andFilterWhere(['like', 'buyer_trip_sheet_number', $this->buyer_trip_sheet_number])->andFilterWhere(['like', 'seller_trip_sheet_number', $this->seller_trip_sheet_number]); return $dataProvider; }
/** * Finds the Trips model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Trips the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Trips::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }