Пример #1
0
 public function update($id)
 {
     $hoadon = Hoadon::findOrFail($id);
     $hoadon->status = 1;
     $hoadon->save();
     echo "oke";
 }
 public function index()
 {
     $count_hodon = Hoadon::count();
     $count_sanpham = Product::count();
     $count_danhgia = Danhgia::count();
     $product = Product::orderBy('id', 'DESC')->take(3)->get()->toArray();
     $donhang = Hoadon::orderBy('id', 'DESC')->take(4)->get();
     return view('backend.home', compact('count_hodon', 'count_sanpham', 'count_danhgia', 'product', 'donhang'));
 }
Пример #3
0
 public function postthanhtoan(CartRequest $request)
 {
     $hoadon = new Hoadon();
     $hoadon->name = $request->txtName;
     $hoadon->email = $request->txtEmail;
     $hoadon->phone = $request->txtPhone;
     $hoadon->addreass = $request->txtAddress;
     $hoadon->status = 0;
     $hoadon->total_qty = $request->total_qty;
     $hoadon->total_price = $request->total_price;
     $hoadon->save();
     $product_hoadon = $hoadon->id;
     $content = Cart::content();
     foreach ($content as $row) {
         if ($row->options->pricesale > 0) {
             $price = $row->options->pricesale;
             $total = $row->options->pricesale * $row->qty;
         } else {
             $price = $row->price;
             $total = $row->price * $row->qty;
         }
         $cthoadon = new Chitiethoadon();
         $cthoadon->id_hoadon = $product_hoadon;
         $cthoadon->id_sanpham = $row->id;
         $cthoadon->soluong = $row->qty;
         $cthoadon->giasp = $price;
         $cthoadon->tong_giasp = $total;
         $cthoadon->save();
     }
     $data = ['name' => $_POST['txtName'], 'dienthoai' => $_POST['txtPhone'], 'diachi' => $_POST['txtAddress'], 'tongdonhang' => $_POST['total_price'], 'soluong' => $_POST['total_qty']];
     Mail::send('emails.ordercart', $data, function ($msg) {
         $msg->from('*****@*****.**', "BooksOnline");
         $msg->to($_POST['txtEmail'])->subject('Cảm ơn bạn đã đặt hàng!Chúng tôi sẽ liên hệ với bạn thời gian sớm nhất');
     });
     Cart::destroy();
     echo "<script>alert('Đơn hàng của bạn đã được gửi')\n\t\twindow.location ='" . url('/') . "';\n\t\t</script>";
 }