Skip to content

Instantly share code, notes, and snippets.

@devalexandre
Created November 13, 2017 13:43
Show Gist options
  • Save devalexandre/ac1f6410a434000f73f1fc760a55970f to your computer and use it in GitHub Desktop.
Save devalexandre/ac1f6410a434000f73f1fc760a55970f to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: alexandre
* Date: 13/11/17
* Time: 09:13
*/
namespace Indev\Shopcart\Controllers;
use Backend\Classes\Controller;
use Gloudemans\Shoppingcart\Facades\Cart;
use Indev\Shopcart\Models\Product;
class ShopcartController extends Controller
{
public function add($id,$qty){
$product = Product::find($id);
$cartItem = Cart::add($product->id,$product->name,$qty,$product->price);
Cart::associate($cartItem->rowId, '\Indev\Shopcart\Models\Product');
}
public function update($rowId,$qty){
Cart::update($rowId,$qty);
return Cart::content();
}
public function remove($rowId){
Cart::remove($rowId);
return Cart::content();
}
public function getList () {
return Cart::content();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment