Answer the question
In order to leave comments, you need to log in
How to register a global variable or get data via API once when loading a page?
There is a method that (for example, checkContract() ) calls the API to another server and requests the status of the contract (open or closed).
Now it is implemented in such a way that through the helper in BLADE, and in the methods of the controllers themselves, there is a constant call to this checkContract() method to check the status status.
And it turns out that when accessing this, the system each time knocks on the API. Those. when loading one page, it can request a contract several times (a couple of times in the blade template), and three times in different methods of different controllers.
Prompt how correctly to implement in such cases. At what point do you need to write the checkContract() method, and write it to a global variable accessible to everyone.
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