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:
Joel Male
2026-05-28 09:25:41 +10:00
parent 4f87bd645c
commit 88a118d81b
4 changed files with 18 additions and 302 deletions
+6 -4
View File
@@ -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