Answer the question
In order to leave comments, you need to log in
Where is the right place to initialize a class to work with the API with several available configurations?
Good afternoon. To work with the API, a library is used that requires several parameters to work (server address, application ID, secret, token, refresh and other data for working with oauth). The system uses several different data sets for connection, and their number changes during the life of the project, so they are placed in a separate Accounts model. There is a need to initialize the library depending on which user is currently working in the system (connection via the account_id field in the User model). I implemented this through a service with a set of static methods (getting an API client instance occurs through MyService::getByUser()), but I would like to use the Service Provider mechanism for this, but I don’t know how to do it correctly (specifically, where exactly should the get Auth::user()->
Links to examples are welcome, I read the documentation on providers :)
Laravel 7.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question