Skip to content

Commit 6d98efe

Browse files
[10.x] Document tags for event listeners (#9241)
* Update horizon.md * Update horizon.md * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 5eab644 commit 6d98efe

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

horizon.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,25 @@ If you would like to manually define the tags for one of your queueable objects,
364364
}
365365
}
366366

367+
<a name="manually-tagging-event-listeners"></a>
368+
#### Manually Tagging Event Listeners
369+
370+
When retrieving the tags for a queued event listener, Horizon will automatically pass the event instance to the `tags` method, allowing you to add event data to the tags:
371+
372+
class SendRenderNotifications implements ShouldQueue
373+
{
374+
/**
375+
* Get the tags that should be assigned to the listener.
376+
*
377+
* @return array<int, string>
378+
*/
379+
public function tags(VideoRendered $event): array
380+
{
381+
return ['video:'.$event->video->id];
382+
}
383+
}
384+
385+
367386
<a name="notifications"></a>
368387
## Notifications
369388

0 commit comments

Comments
 (0)