AppServiceProvider.php 1.3 KB

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