Category: Laravel, Laravel, PHP, PHP, api, api, javascript, javascript

· October 3, 2020 · ⋆ Laravel Essentially, if you want to inject something which can be swappable anytime, you can do this by “biding” that into the service container.

So, what we can do is define an interface that contains certain methods called payment and discount like so. And now if we want to use a payment method in our application, we can create a class for that payment method which will implement the App\Payment\Contract\PaymentInterface.

And if we want to resolve App\Payment\Contract\PaymentInterface to App\Payment\Stripe in the PurchaseController controller, we can define the binding like so.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners