AppServiceProvider.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Providers;
  3. use App\Models\Config;
  4. use App\Models\Node;
  5. use App\Models\Order;
  6. use App\Models\RuleGroup;
  7. use App\Models\User;
  8. use App\Models\UserGroup;
  9. use App\Observers\ConfigObserver;
  10. use App\Observers\NodeObserver;
  11. use App\Observers\OrderObserver;
  12. use App\Observers\RuleGroupObserver;
  13. use App\Observers\UserGroupObserver;
  14. use App\Observers\UserObserver;
  15. use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
  16. use Illuminate\Support\ServiceProvider;
  17. use URL;
  18. class AppServiceProvider extends ServiceProvider
  19. {
  20. /**
  21. * Register any application services.
  22. *
  23. * @return void
  24. */
  25. public function register()
  26. {
  27. if ($this->app->isLocal()) {
  28. $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
  29. $this->app->register(TelescopeServiceProvider::class);
  30. $this->app->register(IdeHelperServiceProvider::class);
  31. }
  32. }
  33. /**
  34. * Bootstrap any application services.
  35. *
  36. * @return void
  37. */
  38. public function boot()
  39. {
  40. // 检测是否强制跳转https
  41. if (env('REDIRECT_HTTPS', false)) {
  42. URL::forceScheme('https');
  43. }
  44. Config::observe(ConfigObserver::class);
  45. Node::observe(NodeObserver::class);
  46. Order::observe(OrderObserver::class);
  47. RuleGroup::observe(RuleGroupObserver::class);
  48. UserGroup::observe(UserGroupObserver::class);
  49. User::observe(UserObserver::class);
  50. }
  51. }