<?php
namespace App\Http\Controllers;
use App\Cart;
use Illuminate\Http\Request;
class CartController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$user = $request->user();
return view('cart.index', compact('user'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$cart = new Cart;
$cart->user_id = $request->user()->id;
$cart->product_id = $request->product_id;
$cart->amount = $request->amount;
$cart->save();
return [];
}
/**
* Display the specified resource.
*
* @param \App\Cart $cart
* @return \Illuminate\Http\Response
*/
public function show(Cart $cart)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Cart $cart
* @return \Illuminate\Http\Response
*/
public function edit(Cart $cart)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Cart $cart
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Cart $cart)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Cart $cart
* @return \Illuminate\Http\Response
*/
public function destroy($id, Request $request)
{
$request->user()->carts()->where('id', $id)->delete();
return [];
}
}