Complete the code to define a listener class in Laravel.
class UserRegisteredListener { public function [1]($event) { // handle the event } }
The handle method is the standard method Laravel calls when the event is fired.
Complete the code to register a listener for an event in Laravel's EventServiceProvider.
protected $listen = [
UserRegistered::class => [
[1]::class,
],
];The listener class name should be listed here to handle the event.
Fix the error in the listener method signature to properly receive the event.
public function handle([1] $event) {
// process event
}The listener's handle method must type hint the event class it listens to.
Fill both blanks to dispatch an event and listen to it with a listener.
event(new [1]($user)); protected $listen = [ [2]::class => [ SendWelcomeEmail::class, ], ];
The event dispatched and the event listened to must be the same class.
Fill all three blanks to create a listener class that handles an event and logs a message.
use Illuminate\Support\Facades\Log; class [1] { public function handle([2] $event) { Log::info('[3] event handled'); } }
The listener class name, the event type in the handle method, and the event name in the log message must correspond.