AppServiceProvider.php 1.2 KB

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