Guest User

Untitled

a guest
Apr 17th, 2017
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use App\Hotel;
  6. use Illuminate\Http\Request;
  7. use Gloudemans\Shoppingcart\Facades\Cart;
  8.  
  9. class ShoppingCartController extends Controller
  10. {
  11.     public function getCart()
  12.     {
  13.         $cart = Cart::content();
  14.         return view('reservation.shopping-cart', [
  15.             'cart' => $cart,
  16.         ]);
  17.     }
  18.  
  19.     public function postCart(Request $request, $id)
  20.     {
  21.         $hotel = Hotel::find($id);
  22.  
  23.         $cart = Cart::add($hotel->id, $hotel->name, 1, 9.99);
  24.  
  25.         $request->session()->put('cart', $cart);
  26.  
  27.         return $this->getCart();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment