AppServiceProvider.php 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Providers;
  3. use Barryvdh\Debugbar\Facades\Debugbar;
  4. use Illuminate\Support\Facades\Artisan;
  5. use Illuminate\Support\Facades\ParallelTesting;
  6. use Illuminate\Support\Facades\Request;
  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. $allowedIPs = array_map('trim', explode(',', config('app.debug_allowed_ips')));
  16. $allowedIPs = array_filter($allowedIPs);
  17. if (empty($allowedIPs)) {
  18. return;
  19. }
  20. if (in_array(Request::ip(), $allowedIPs)) {
  21. Debugbar::enable();
  22. } else {
  23. Debugbar::disable();
  24. }
  25. }
  26. /**
  27. * Bootstrap any application services.
  28. */
  29. public function boot(): void
  30. {
  31. ParallelTesting::setUpTestDatabase(function (string $database, int $token) {
  32. Artisan::call('db:seed');
  33. });
  34. }
  35. }