AppServiceProvider.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Providers;
  3. use App\Notification\DingDingRobot;
  4. use Illuminate\Pagination\Paginator;
  5. use Illuminate\Support\Facades\Schema;
  6. use Illuminate\Support\ServiceProvider;
  7. class AppServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * Bootstrap any application services.
  11. *
  12. * @return void
  13. */
  14. public function boot()
  15. {
  16. //
  17. Schema::defaultStringLength(191);
  18. // Laravel 5.7兼容的分页设置
  19. Paginator::defaultView('vendor.pagination.bootstrap-4');
  20. Paginator::defaultSimpleView('vendor.pagination.simple-bootstrap-4');
  21. }
  22. /**
  23. * Register any application services.
  24. *
  25. * @return void
  26. */
  27. public function register()
  28. {
  29. $this->app->singleton(DingDingRobot::class, function () {
  30. return new DingDingRobot(env('DINGDING_ACCESS_TOKEN'), env('DINGDING_SECRET'));
  31. });
  32. // 仅在测试环境使用信任自签名证书的 SQL Server 连接器 (兼容 ODBC Driver 18)
  33. if (env('APP_ENV') === 'testing') {
  34. $this->app->singleton('db.factory', function ($app) {
  35. return new \App\Connectors\TrustConnectionFactory($app);
  36. });
  37. }
  38. }
  39. }