/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = InvoiceItem::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->andFilterWhere(['id' => $this->id, 'invoice_id' => $this->invoice_id, 'employee_id' => $this->employee_id, 'hotel_rate' => $this->hotel_rate, 'employee_rate' => $this->employee_rate, 'amount' => $this->amount]); return $dataProvider; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { try { Log::error($id); $admin = \Auth::User(); if (!$admin) { return $this->failResponse('admin not logged in'); } $invoiceItemObj = InvoiceItem::find($id); if (count($invoiceItemObj) == 0) { return $this->failResponse('customer id not found'); } $invoiceItemObj->delete(); return $this->successResponse('customer deleted successfully'); } catch (\Exception $e) { Log::error("error in customer controller"); return $this->failResponse($e->getMessage()); } }