您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CurrencyServiceProvider.php 701B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Providers;
  3. use App\Contracts\CurrencyHandler;
  4. use App\Services\CurrencyService;
  5. use GuzzleHttp\Client;
  6. use Illuminate\Contracts\Foundation\Application;
  7. use Illuminate\Support\ServiceProvider;
  8. class CurrencyServiceProvider extends ServiceProvider
  9. {
  10. public function register(): void
  11. {
  12. $this->app->bind(CurrencyHandler::class, function (Application $app) {
  13. $apiKey = config('services.currency_api.key');
  14. $baseUrl = config('services.currency_api.base_url');
  15. $client = $app->make(Client::class);
  16. return new CurrencyService($apiKey, $baseUrl, $client);
  17. });
  18. }
  19. public function boot(): void
  20. {
  21. }
  22. }