Advertisement
Guest User

ShoppingCart Component

a guest
May 3rd, 2021
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Livewire;
  4.  
  5. use Livewire\Component;
  6. use Cart;
  7.  
  8. class CartComponent extends Component
  9. {
  10.     public int $qty = 0;
  11.  
  12.     public function increaseQuantity($rowId)
  13.     {
  14.         $product = Cart::get($rowId);
  15.         $qty = $product->qty + 1;
  16.         Cart::update($rowId, $qty);
  17.     }
  18.  
  19.     public function decreaseQuantity($rowId)
  20.     {
  21.         $product = Cart::get($rowId);
  22.         $qty = $product->qty - 1;
  23.         Cart::update($rowId, $qty);
  24.     }
  25.     public function render()
  26.     {
  27.         return view('livewire.cart-component')->layout('_layouts.master');
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement