AppServiceProvider.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\Support\ServiceProvider;
  8. class AppServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * Register any application services.
  12. */
  13. public function register(): void
  14. {
  15. if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
  16. $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
  17. $this->app->register(TelescopeServiceProvider::class);
  18. }
  19. }
  20. /**
  21. * Bootstrap any application services.
  22. */
  23. public function boot(): void
  24. {
  25. // Data::use(CarbonImmutable::class);
  26. // As there are concerned with application correctness
  27. // leave them enable all the time.
  28. Model::preventAccessingMissingAttributes();
  29. Model::preventSilentlyDiscardingAttributes();
  30. // Since this is a performance concern only, don't halt
  31. // production for violations.
  32. Model::preventLazyLoading(!$this->app->isProduction());
  33. Relation::enforceMorphMap([
  34. // TODO
  35. ]);
  36. }
  37. }