public static function insert($data) { $detailorder = new detailorder(); $detailorder->fill($data); $detailorder->save(); }
public function postDelete() { $order = order::find(Input::get('id')); if ($order->delete()) { $orderdetail = detailorder::where('orderid', Input::get('id'))->delete(); return json_encode(array('result' => 1)); } return json_encode(array('result' => -1, 'message' => 'Có lỗi. Xóa thất bại')); }
public function delete() { $order = detailorder::where('productID', Input::get('id'))->get(); if (count($order) > 0) { return Redirect::to('admin/product/recyclebin')->with(['message' => 'Sản phẩm "' . Input::get('title') . '" đã có đơn đặt hàng. Bạn không thể xóa.']); } $product = product::find(Input::get('id')); if ($product->delete()) { DB::table('detailproduct')->where('productID', Input::get('id'))->delete(); return Redirect::to('admin/product/recyclebin')->with(['message' => 'Xóa thành công sản phẩm "' . Input::get('title') . '"']); } else { return Redirect::to('admin/product/recyclebin')->with(['message' => 'Có lỗi xóa sản phẩm "' . Input::get('title') . '" thất bại. Vui lòng thử lại.']); } }