AppServiceProvider.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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(\Laravel\Telescope\TelescopeServiceProvider::class);
  19. $this->app->register(TelescopeServiceProvider::class);
  20. $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
  21. $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
  22. }
  23. if (File::exists(base_path().'/.env') && Schema::hasTable('config') && DB::table('config')->exists()) {
  24. $this->app->register(SettingServiceProvider::class);
  25. }
  26. }
  27. /**
  28. * Bootstrap any application services.
  29. */
  30. public function boot(): void
  31. {
  32. Paginator::useBootstrap();
  33. // 检测是否强制跳转https
  34. if (config('session.secure')) {
  35. URL::forceScheme('https');
  36. }
  37. }
  38. }