first test passing
This commit is contained in:
@@ -26,6 +26,9 @@ class CartItemsController extends AppController
|
||||
// component work only for specified methods.
|
||||
'actions' => ['add'],
|
||||
]);
|
||||
if ($this->components()->has('Authorization')) {
|
||||
$this->Authorization->skipAuthorization();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,6 @@ class CartItemsController extends AppController
|
||||
public function add()
|
||||
{
|
||||
$this->request->allowMethod(['post', 'put', 'patch']);
|
||||
$this->Authorization->skipAuthorization();
|
||||
|
||||
Log::debug(print_r('$this->request->getData()', true));
|
||||
Log::debug(print_r($this->request->getData(), true));
|
||||
@@ -49,11 +51,11 @@ class CartItemsController extends AppController
|
||||
$postData['price'] = $price;
|
||||
$postData['subtotal'] = isset($price) ? bcmul("$price", "$qty", 5) : null;
|
||||
|
||||
$newCartItem = $this->Carts->CartItems->newEntity($postData, [
|
||||
$newCartItem = $this->CartItems->newEntity($postData, [
|
||||
'validate' => Configure::readOrFail('CakeCarts.CartItems.requirePricing') ? 'requirePricing' : 'default',
|
||||
]);
|
||||
|
||||
if ($this->Carts->CartItems->save($newCartItem)) {
|
||||
if ($this->CartItems->save($newCartItem)) {
|
||||
$this->Flash->success('Added to cart');
|
||||
|
||||
return $this->redirect($this->referer([
|
||||
@@ -62,9 +64,9 @@ class CartItemsController extends AppController
|
||||
'action' => 'index'
|
||||
]));
|
||||
}
|
||||
Log::debug(print_r('$newCartItem->getErrors()', true));
|
||||
Log::debug(print_r($newCartItem->getErrors(), true));
|
||||
|
||||
// Log::debug(print_r('$newCartItem->getErrors()', true));
|
||||
// Log::debug(print_r($newCartItem->getErrors(), true));
|
||||
dd(print_r($newCartItem->getErrors(), true));
|
||||
$this->Flash->error('Failed to add to cart.');
|
||||
|
||||
return $this->redirect($this->referer([
|
||||
@@ -91,7 +93,6 @@ class CartItemsController extends AppController
|
||||
->firstOrFail();
|
||||
|
||||
$this->ShoppingCart->checkIfIsOwnCart($cartItem->cart);
|
||||
$this->Authorization->skipAuthorization();
|
||||
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$postData = $this->request->getData();
|
||||
@@ -142,7 +143,6 @@ class CartItemsController extends AppController
|
||||
->firstOrFail();
|
||||
|
||||
$this->ShoppingCart->checkIfIsOwnCart($cartItem->cart);
|
||||
$this->Authorization->skipAuthorization();
|
||||
|
||||
unset($cartItem->cart);
|
||||
if ($this->CartItems->delete($cartItem)) {
|
||||
|
||||
Reference in New Issue
Block a user