Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
namespace App\Controller;
use Cart\Model\Table\Cart;
use Cake\Network\Exception\NotFoundException;
class CartController extends AppController {
public function index()
$cart = Cart::factory();
$products = $cart->all();
public function add($id=null)
$product = $this->Products->find('all',[
if (empty($product)) {
throw new NotFoundException("Artefact not found - Artefato não encontrado");
$product->qtd = 1;
$cart = Cart::factory();
return $this->redirect(['action'=>'index']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment