AppServiceProvider.php 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Support\ServiceProvider;
  4. use Illuminate\Support\Facades\URL;
  5. class AppServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * Register any application services.
  9. */
  10. public function register(): void
  11. {
  12. // 注册 MathRecSys 服务
  13. $this->app->singleton(\App\Services\MathRecSysService::class, function () {
  14. return new \App\Services\MathRecSysService();
  15. });
  16. // 注册知识图谱服务
  17. $this->app->singleton(\App\Services\KnowledgeGraphService::class, function ($app) {
  18. return new \App\Services\KnowledgeGraphService(
  19. $app->make(\App\Services\MathRecSysService::class)
  20. );
  21. });
  22. }
  23. /**
  24. * Bootstrap any application services.
  25. */
  26. public function boot(): void
  27. {
  28. if (config('app.env') === 'production') {
  29. URL::forceScheme('https');
  30. }
  31. }
  32. }