---
title: "Events — Posts for Laravel | Roundly"
description: "PostPublished, PostScheduled, PostArchived and PostDrafted — one per lifecycle transition, each carrying the post id."
url: https://roundly-consulting.com/open-source/docs/posts-for-laravel/events
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Posts for Laravel](https://roundly-consulting.com/open-source/docs/posts-for-laravel.md)

# Events

Each lifecycle transition dispatches an event from RoundlyConsulting\\Posts\\Events carrying the post’s id as public readonly int|string $postId:

| Event | Dispatched by |
| --- | --- |
| `PostPublished` | publish(), create() of a Published post, and publishDue() / posts:publish-scheduled |
| `PostScheduled` | schedule(), and create() of a Scheduled post |
| `PostArchived` | archive() — also the moderation listener |
| `PostDrafted` | unpublish() — also the moderation listener |

```php
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Posts\Events\PostPublished;

Event::listen(PostPublished::class, fn (PostPublished $e) => Cache::forget("post:{$e->postId}"));
```

Events fire only when the status actually changes — every schedule() fires PostScheduled, since it always moves the date — so a repeated call or a racing publishDue() run never fires one twice.

The package itself listens to PostPublished (to warm media variants) and to reports’ ReportResolved and ReportThresholdReached (to auto-unpublish). Creating a post as Published or Scheduled fires PostPublished or PostScheduled as well.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/posts-for-laravel.md)
