AppServiceProvider.php 1.1 KB

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