Back

Artisans! I have a question.

In a package I'm creating the current way for using the class is by first using the Quickpay::api() method, and then tacking on any other method.

How could I change my code to skip this Quickpay::api()->payments()->create() and just go directly to Quickpay::payments()->create();

github.com/mortenebak/laravel-quickpay



Any help appriciated :)

2

206

Use the service container with a binding (or singleton) in your ServiceProvider to inject a QuickPay instance instead of wiring it up in the constructor. This should allow to to skip the static constructor / api() method call.

1

305

Plus, he would need to switch all the methods to static.

2

346

In response to @santigarcor

That wouldn’t work out very well. The static methods wouldn’t have access to the instance properties and therefore the injected client. A static call on the Quickpay class would basically bypass the service container.

398

  • No matching results...
  • Searching...

/ 1000