AppServiceProvider.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Providers;
  3. use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
  4. use Carbon\Carbon;
  5. use Illuminate\Support\ServiceProvider;
  6. use App\Services\ChuanglanSmsService;
  7. use App\Services\AliSmsService;
  8. class AppServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * Bootstrap any application services.
  12. *
  13. * @return void
  14. */
  15. public function boot()
  16. {
  17. Carbon::setLocale('zh');
  18. // 创蓝短信
  19. $this->app->singleton('ChuanglanSms', function ($app) {
  20. return new ChuanglanSmsService(
  21. Config('services.chuanglansms.default')
  22. );
  23. });
  24. $this->app->singleton('Sms253', function ($app) {
  25. return new ChuanglanSmsService(
  26. Config('services.chuanglansms.yingxiao')
  27. );
  28. });
  29. // 阿里云短信
  30. $this->app->singleton('AliSms', function ($app) {
  31. return new AliSmsService(
  32. Config('services.alisms.access_key_id'),
  33. Config('services.alisms.access_key_secret')
  34. );
  35. });
  36. }
  37. /**
  38. * Register any application services.
  39. *
  40. * @return void
  41. */
  42. public function register()
  43. {
  44. if ($this->app->environment() == 'local') {
  45. $this->app->register(IdeHelperServiceProvider::class);
  46. }
  47. }
  48. }