EventServiceProvider.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Auth\Events\Registered;
  4. use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
  5. use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
  6. use Illuminate\Support\Facades\Event;
  7. // Указывают *где* нужно расположить файлы для новых классов
  8. // Если пропустить эти строки, то будет использован NS App\Providers
  9. use App\Events\CommentAdded;
  10. use App\Listeners\PremoderateComment;
  11. class EventServiceProvider extends ServiceProvider
  12. {
  13. /**
  14. * The event to listener mappings for the application.
  15. *
  16. * @var array<class-string, array<int, class-string>>
  17. */
  18. protected $listen = [
  19. Registered::class => [
  20. SendEmailVerificationNotification::class,
  21. ],
  22. CommentAdded::class => [
  23. PremoderateComment::class
  24. ]
  25. ];
  26. /**
  27. * Register any events for your application.
  28. */
  29. public function boot(): void
  30. {
  31. //
  32. }
  33. /**
  34. * Determine if events and listeners should be automatically discovered.
  35. */
  36. public function shouldDiscoverEvents(): bool
  37. {
  38. return false;
  39. }
  40. }