Esempio n. 1
0
 public function add($priceId)
 {
     $cart = \App\Cart::whereUserIdAndPriceId($this->user()->id, $priceId)->first();
     if (is_null($cart)) {
         $cart = new \App\Cart();
         $cart->price_id = $priceId;
         $cart->user_id = $this->user()->id;
         $cart->quantity = 1;
     } else {
         $cart->quantity = $cart->quantity + 1;
     }
     $cart->save();
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     App\User::truncate();
     App\Cart::truncate();
     App\Product::truncate();
     factory(App\Product::class, 10)->create();
     factory(App\User::class, 10)->create()->each(function ($user) {
         $user->cart()->saveMany(factory(App\Cart::class, 2)->make());
     });
     Model::reguard();
 }
Esempio n. 3
0
@endsection

@section('content')
  <div class="container">
    <div class="row">
      <h3>สินค้าในตะกร้า</h3>
    </div>
    <div class="row">

      <div class="col l12">

        @if(Auth::user()->Cart->first())
        <table class="cart">
          <?php 
$user = Auth::user();
$cart = App\Cart::where('user_id', '=', $user->id)->where('status', '=', 'pending')->first();
?>
          <thead>
            <th> รูปสินค้า   </th>
            <th> ชื่อสินค้า  </th>
            <th> จำนวนที่สั่งซื้อ </th>
            <th>  ราคา </th>
            <th>  รวม </th>
          </thead>
          <tbody>
          <?php 
$totalPrice;
?>
          @foreach($cart->Product as $product)

          <tr class="list" >
Esempio n. 4
0
 public function show($id)
 {
     return view('catalog.cart.invoice')->with(App\Cart::find($id));
 }