/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Receipt::find(); $query->joinWith(['estimate']); $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->andFilterWhere(['receipt.id' => $this->id, 'receipt.estimate_id' => $this->estimate_id, 'receipt.status' => $this->status, 'receipt.created_date' => $this->created_date, 'receipt.type' => $this->type, 'receipt.iva' => $this->iva, 'estimate.client_id' => $this->client_id]); $query->andFilterWhere(['like', 'number', $this->number]); /** * Convert the to dates to mysql format. * Leave them as null so they are not used * by ActiveQuery::andFilterWhere(). */ $fromDate = null; $toDate = null; if ($this->from_date) { $this->from_date = DateConverter::convert($this->from_date); } if ($this->to_date) { $this->to_date = DateConverter::convert($this->to_date); } $query->andFilterWhere(['>=', 'created_date', $this->from_date]); $query->andFilterWhere(['<=', 'created_date', $this->to_date]); return $dataProvider; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { //Soft delete the patient $receipt = Receipt::find($id); $receipt->delete(); // redirect return redirect()->to('receipt.index')->with('message', trans('messages.receipt-succesfully-deleted')); }