I see, your scenario involves multiple layers of extensions to the PaymentMethodService
class (e.g., first by PaymentGatewayService
, then by BkashGatewayService
), and you want to call PaymentMethodService
but ensure that all of its extensions (including those applied by various service providers) are taken into account.
In Laravel, when you bind a class to the service container, it will always resolve the last binding unless you explicitly manage the resolution. This can cause issues when you have multiple extensions happening in different service providers, as each extension might overwrite the previous one in terms of the container's resolution behavior.
To handle multiple extensions without facing issues where a facade or the service container always resolves the final binding, here's a more dynamic approach:
- Use Multiple Bindings: You can make the service container aware of all the extended classes (lik