AppServiceProvider.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Providers;
  3. use Carbon\CarbonImmutable;
  4. //use Illuminate\Support\Facades\Data;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\Relations\Relation;
  7. use Illuminate\Http\Resources\Json\JsonResource;
  8. use Illuminate\Support\Facades\Http;
  9. use Illuminate\Support\ServiceProvider;
  10. class AppServiceProvider extends ServiceProvider
  11. {
  12. /**
  13. * Register any application services.
  14. */
  15. public function register(): void
  16. {
  17. if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
  18. $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
  19. $this->app->register(TelescopeServiceProvider::class);
  20. }
  21. }
  22. /**
  23. * Bootstrap any application services.
  24. */
  25. public function boot(): void
  26. {
  27. // Data::use(CarbonImmutable::class);
  28. // As there are concerned with application correctness
  29. // leave them enable all the time.
  30. Model::preventAccessingMissingAttributes();
  31. Model::preventSilentlyDiscardingAttributes();
  32. // Since this is a performance concern only, don't halt
  33. // production for violations.
  34. Model::preventLazyLoading(!$this->app->isProduction());
  35. Relation::enforceMorphMap([
  36. // TODO
  37. ]);
  38. JsonResource::withoutWrapping();
  39. Http::macro('inference', fn() => Http::baseUrl(config('services.inference.host'))->timeout(120));
  40. }
  41. }