Error Unresolvable dependency resolving [Parameter #0 [
Im trying to implement darryldecode/laravelshoppingcart in my Laravel App. It was working ok with laravel 7, but now I cannot make it work. The error I receive is:
Illuminate\Contracts\Container\BindingResolutionException Unresolvable dependency resolving [Parameter #0 [ <required> $session ]] in class Darryldecode\Cart\Cart
We have a cartserviceprovider developed taking into consideration https://github.com/darryldecode/laravelshoppingcart#instances guidelines and with the following code at the service provider:
public function register()
{
$this->app->singleton(Cart::class, function ($app) {
return new Cart(
$app['session'],
$app['events'],
'cart',
session()->getId()
);
});
$this->app->alias(Cart::class, 'cart');
}
Darryldecode\Cart\Cart library displays the following code to be in compliance:
public function __construct($session, $events, $instanceName, $session_key, $config)
{
$this->events = $events;
$this->session = $session;
$this->instanceName = $instanceName;
$this->sessionKey = $session_key;
$this->sessionKeyCartItems = $this->sessionKey . '_cart_items';
$this->sessionKeyCartConditions = $this->sessionKey . '_cart_conditions';
$this->config = $config;
$this->currentItem = null;
$this->fireEvent('created');
}
And I believe $session is covered by passing the singleton app->singleton ...... session()->getId()
Im using the following code to implement a class Cart
class Cart extends DarryldecodeCart implements JsonSerializable
{
/**
* Get the current instance.
*
* @return $this
*/
public function instance()
{
return $this;
}
any guideance appreciated.
from Recent Questions - Stack Overflow https://ift.tt/3euPLA3
https://ift.tt/eA8V8J
Comments
Post a Comment