| Conditions | 3 |
| Paths | 1 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Darryldecode\Cart; |
||
| 31 | public function register() |
||
| 32 | { |
||
| 33 | $this->mergeConfigFrom(__DIR__.'/config/config.php', 'shopping_cart'); |
||
| 34 | |||
| 35 | $this->app->singleton('cart', function($app) |
||
| 36 | { |
||
| 37 | $storageClass = config('shopping_cart.storage'); |
||
| 38 | $eventsClass = config('shopping_cart.events'); |
||
| 39 | |||
| 40 | $storage = $storageClass ? new $storageClass() : $app['session']; |
||
| 41 | $events = $eventsClass ? new $eventsClass() : $app['events']; |
||
| 42 | $instanceName = 'cart'; |
||
| 43 | |||
| 44 | // default session or cart identifier. This will be overridden when calling Cart::session($sessionKey)->add() etc.. |
||
| 45 | // like when adding a cart for a specific user name. Session Key can be string or maybe a unique identifier to bind a cart |
||
| 46 | // to a specific user, this can also be a user ID |
||
| 47 | $session_key = '4yTlTDKu3oJOfzD'; |
||
| 48 | |||
| 49 | return new Cart( |
||
| 50 | $storage, |
||
| 51 | $events, |
||
| 52 | $instanceName, |
||
| 53 | $session_key, |
||
| 54 | config('shopping_cart') |
||
| 55 | ); |
||
| 56 | }); |
||
| 57 | } |
||
| 58 | |||
| 69 |