Hello everyone, tell me who knows how to get access to Auth :: user () in the service provider public function register() { $this->app->singleton(Cart::class, function () { return new Cart( new HybridStorage(Auth::user(), 'cart'), new DynamicCost(new SimpleCost()) ); }); } public function register() { $this->app->singleton(Cart::class, function () { return new Cart( new HybridStorage(Auth::user(), 'cart'), new DynamicCost(new SimpleCost()) ); }); }
Auth :: user () is always null, or there may be another way of binding the interface to the implementation.