AppServiceProvider.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Providers;
  3. use DB;
  4. use File;
  5. use Illuminate\Pagination\Paginator;
  6. use Illuminate\Support\ServiceProvider;
  7. use Schema;
  8. use URL;
  9. use function config;
  10. class AppServiceProvider extends ServiceProvider
  11. {
  12. /**
  13. * Register any application services.
  14. */
  15. public function register(): void
  16. {
  17. if ($this->app->isLocal() && config('app.debug')) {
  18. $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
  19. $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
  20. if (class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
  21. $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
  22. $this->app->register(TelescopeServiceProvider::class);
  23. }
  24. }
  25. if (Schema::hasTable('config') && File::exists(base_path().'/.env') && DB::table('config')->exists()) {
  26. $this->app->register(SettingServiceProvider::class);
  27. }
  28. }
  29. /**
  30. * Bootstrap any application services.
  31. */
  32. public function boot(): void
  33. {
  34. Paginator::useBootstrap();
  35. // 检测是否强制跳转https
  36. if (config('session.secure')) {
  37. URL::forceScheme('https');
  38. }
  39. }
  40. }