Proper use of Laravel program logic to call an API?

I am writing a translator API that will call various other APIs to perform the translation depending on the service requested. I would have thought that I should put this in a controller, but what if I need to access the translator class from another controller or in a view?

Should I put part of it in the model?

For speed, I don't want you to call the service as an external URL, using Request::create()if it's an internal request.

Something like this works in the view, but I feel that there should be a more elegant way to do this.

{{ App::make('TranslatorController')->show($text, $to, App::getLocale()); }}
+4
source share
1 answer

, !

, /, . /API. . Laravel, , , .

, !

0

Source: https://habr.com/ru/post/1537059/


All Articles