[text] cek deh

Viewer

  1. Route::prefix("product")->group(function (){
  2.  
  3.     Route::get('/', function(){
  4.  
  5.         $products = Product::all();
  6.  
  7.         $carts = Transaction::where("user_id", Auth::user()->id)->where("status", 1)->where("type", 2)->get();
  8.  
  9.         $checkouts = Transaction::where("user_id", Auth::user()->id)->where("status", 1)->where("type", 2)->get();
  10.  
  11.         $balance = Balance::where("user_id", Auth::user()->id)->first();
  12.  
  13.  
  14.  
  15.         $total_cart = 0;
  16.  
  17.         $total_checkout = 0;
  18.  
  19.  
  20.  
  21.         foreach($carts as $cart){
  22.  
  23.             $total_cart += ($cart->product->price * $cart->qty);
  24.  
  25.         }
  26.  
  27.  
  28.  
  29.         foreach($checkouts as $checkout){
  30.  
  31.             $total_checkout += ($checkout->product->price * $checkout->qty);
  32.  
  33.         }
  34.  
  35.  
  36.  
  37.         return view("product.index", [
  38.  
  39.             "products" => $products,
  40.  
  41.             "carts" => $carts,
  42.  
  43.             "checkouts" => $checkouts,
  44.  
  45.             "total_cart" => $total_cart,
  46.  
  47.             "total_checkout" => $total_checkout,
  48.  
  49.             "balance" => $balance
  50.  
  51.         ]);

Editor

You can edit this paste and save as new:


File Description
  • cek deh
  • Paste Code
  • 23 Jan-2022
  • 1.04 Kb
You can Share it: