Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static API class implementation #40

Open
jcandan opened this issue Apr 6, 2022 · 0 comments
Open

Static API class implementation #40

jcandan opened this issue Apr 6, 2022 · 0 comments

Comments

@jcandan
Copy link

jcandan commented Apr 6, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant