mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
feat: make SessionDriver constructor args optional with app() defaults
new SessionDriver() now works out of the box in a Laravel app, resolving the session and session ID from the container. Explicit args still work as before. Also ignores .claude/ directory from version control.
This commit is contained in:
@@ -13,11 +13,13 @@ class SessionDriver implements CartDriver
|
||||
private string $conditionsKey;
|
||||
|
||||
public function __construct(
|
||||
private mixed $session,
|
||||
private string $sessionKey,
|
||||
private mixed $session = null,
|
||||
private ?string $sessionKey = null,
|
||||
) {
|
||||
$this->itemsKey = $sessionKey . '_cart_items';
|
||||
$this->conditionsKey = $sessionKey . '_cart_conditions';
|
||||
$this->session ??= app('session');
|
||||
$this->sessionKey ??= $this->session->getId();
|
||||
$this->itemsKey = $this->sessionKey . '_cart_items';
|
||||
$this->conditionsKey = $this->sessionKey . '_cart_conditions';
|
||||
}
|
||||
|
||||
public function getSessionKey(): string
|
||||
|
||||
Reference in New Issue
Block a user