model icon indicating copy to clipboard operation
model copied to clipboard

Static API class implementation

Open jcandan opened this issue 3 years ago • 0 comments

Your example is that of a static API class: API::post('/items', $this->attributes);.

Currently, my custom API client is injected into my controller and not static. This allows me to authenticate in the constructor and call the API from the controller's instance.

I would like to use this package to define a model for the controller to use instead. However, being new to Laravel and assuming I cannot inject my API Client into my model, I tried to convert it to a static class. However, it seems to me this would mean I would need to run the authentication for every call. Though, thinking about this out loud, perhaps I can store the token in session.

Any thoughts on this? Am I missing something obvious?

jcandan avatar Apr 06 '22 14:04 jcandan