| Conditions | 3 |
| Paths | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function register() |
||
| 34 | { |
||
| 35 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'shopping-cart'); |
||
| 36 | |||
| 37 | $this->app->singleton('cart', function ($app) { |
||
| 38 | if ($app['session']->has('cart')) { |
||
| 39 | return CartManager::fromSessionIdentifier($app['session']->get('cart')); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($app['auth']->check()) { |
||
| 43 | return CartManager::fromUserId($app['auth']->user()); |
||
| 44 | } |
||
| 45 | |||
| 46 | return new CartManager(new Cart()); |
||
| 47 | }); |
||
| 48 | |||
| 49 | $this->app->alias('cart', CartManager::class); |
||
| 50 | $this->app->alias('cart', CartContract::class); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |