You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
858 B
37 lines
858 B
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Cart\CartCollection;
|
|
use App\Cart\CashDraft;
|
|
use App\Cart\CreditDraft;
|
|
use App\Cart\Item;
|
|
use App\Product;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CartController extends Controller
|
|
{
|
|
private $cart;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->cart = new CartCollection;
|
|
}
|
|
public function add(Request $request, $type)
|
|
{
|
|
if ($type == 1)
|
|
$this->cart->add(new CashDraft);
|
|
else
|
|
$this->cart->add(new CreditDraft);
|
|
|
|
return redirect()->route('cart.index', $item->draftKey);
|
|
}
|
|
|
|
public function addDraftItem(Request $request, $draftKey, Product $product)
|
|
{
|
|
$item = new Item($product, $request->qty);
|
|
$this->cart->addItemToDraft($draftKey, $item);
|
|
|
|
return redirect()->route('cart.index', $item->draftKey);
|
|
}
|
|
}
|