/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = OrderDetail::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(['order_detail_id' => $this->order_detail_id, 'order_id' => $this->order_id, 'product_id' => $this->product_id, 'qty_ordered' => $this->qty_ordered, 'qty_in_stock' => $this->qty_in_stock, 'qty_refunded' => $this->qty_refunded, 'qty_returned' => $this->qty_returned, 'product_group_id' => $this->product_group_id, 'product_group_price' => $this->product_group_price, 'supplier_id' => $this->supplier_id, 'supplier_price' => $this->supplier_price, 'product_price' => $this->product_price, 'date_added' => $this->date_added, 'date_update' => $this->date_update]); return $dataProvider; }
public function getOrderDetail($orderId) { return OrderDetail::find()->where(['orderId' => $orderId])->all(); }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Customers the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function getModelItems($id) { $model = OrderDetail::find()->where(['orderId' => $id])->all(); return $model; /*if (($model = OrderDetail::find()->where(['orderId' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); }*/ }
/** * @param $id * @return bool */ public function deleteItem($id) { $order_detail = OrderDetail::find($id); $order = $order_detail->order; $subtotal = $order_detail->subtotal; if ($order_detail->delete()) { $order->total = $order->total - $subtotal; $order->save(); return true; } return false; }