Events Flashcards

1
Q

Creating Event & Listener

A

php artisan make:event UserEvent

php artisan make:listener UserListener –event=UserEvent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Register for event and listener

A

Go to App/providers/EventserviceProvider

don’‘t forget to input event&lister file
UserEvent::class =>[
UserListener::class,
]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Call event

A

Route::get(‘/event’,function (){
$array=[“John”,”Henry”,”Philli”];
UserEvent::dispatch($array);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Working from Listener file

A
in UserListener file
public function handle(UserEvent $event)
    {
        foreach ($event->users as $user){
            echo $user;
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly