feat: clean up and starting documentation

This commit is contained in:
Joel Male
2025-02-25 14:53:49 +10:00
parent 8d6e1bcc26
commit ec99aa0563
9 changed files with 111 additions and 73 deletions
+8 -13
View File
@@ -35,24 +35,19 @@ public function register()
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'cart');
$this->app->singleton('cart', function ($app) {
$storageClass = config('cart.storage');
$eventsClass = config('cart.events');
$config = config('cart');
$events = $app['events'];
$storage = $storageClass ? new $storageClass : $app['session'];
$events = $eventsClass ? new $eventsClass : $app['events'];
$instanceName = 'cart';
// default session or cart identifier. This will be overridden when calling Cart::session($sessionKey)->add() etc..
// like when adding a cart for a specific user name. Session Key can be string or maybe a unique identifier to bind a cart
// to a specific user, this can also be a user ID
$session_key = '4yTlTDKu3oJOfzD';
$storage = $config['driver'] === 'database'
? new $config['storage']['database']['model']
: $app['session'];
return new Cart(
$storage,
$events,
$instanceName,
$session_key,
config('cart')
'cart',
'4yTlTDKu3oJOfzD',
$config
);
});
}