You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -346,7 +346,9 @@ The *`getData()`* method is used to return the payload of data that can be used
346
346
347
347
#### Receiving multiple events in a single webhook
348
348
349
-
Sometimes the services will send multiple event payloads in a single webhook. In that case, you may return an array of events from the `getEvent` method and Receiver will handle them each individually.
349
+
Sometimes the services will send multiple event payloads in a single webhook.
350
+
351
+
In this scenario you may return an array of mapped events from the `getEvent` method and Receiver will handle them each individually.
350
352
351
353
For example, if the payload looks like this:
352
354
```json
@@ -371,10 +373,14 @@ You may return the events from the `getEvent` method like so:
371
373
```php
372
374
public function getEvent(): array
373
375
{
374
-
return [
375
-
'channel_occupied',
376
-
'member_added',
377
-
];
376
+
return $events = $this->request
377
+
->collect('events')
378
+
->mapToGroups(
379
+
fn ($item) => [
380
+
$item['name'] => $item
381
+
]
382
+
)
383
+
->toArray();
378
384
}
379
385
```
380
386
Receiver will then handle each event individually.
0 commit comments