mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 15:41:24 +00:00
Added new events adding, updating, removing.
This commit is contained in:
14
src/Cart.php
14
src/Cart.php
@@ -167,11 +167,15 @@ class Cart
|
|||||||
$content->put($item->rowId, $item);
|
$content->put($item->rowId, $item);
|
||||||
|
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->events->dispatch('cart.added', $item);
|
$this->events->dispatch('cart.adding', $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
|
if ($dispatchEvent) {
|
||||||
|
$this->events->dispatch('cart.added', $item);
|
||||||
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,10 +226,12 @@ class Cart
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->events->dispatch('cart.updated', $cartItem);
|
$this->events->dispatch('cart.updating', $cartItem);
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
|
$this->events->dispatch('cart.updated', $cartItem);
|
||||||
|
|
||||||
return $cartItem;
|
return $cartItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +250,11 @@ class Cart
|
|||||||
|
|
||||||
$content->pull($cartItem->rowId);
|
$content->pull($cartItem->rowId);
|
||||||
|
|
||||||
$this->events->dispatch('cart.removed', $cartItem);
|
$this->events->dispatch('cart.removing', $cartItem);
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
|
$this->events->dispatch('cart.removed', $cartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user