---
title: "Events — Connections for Laravel | Roundly"
description: "Nine lifecycle events for creates, updates, removals, permission changes, invitations, status changes, restores and expiry warnings."
url: https://roundly-consulting.com/open-source/docs/connections-for-laravel/events
language: en
---

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

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

# Events

When events.enabled is true (the default), the following events are dispatched. Each carries the affected Connection:

```php
use RoundlyConsulting\Connections\Events\ConnectionCreated;
use RoundlyConsulting\Connections\Events\ConnectionUpdated;
use RoundlyConsulting\Connections\Events\ConnectionRemoved;
use RoundlyConsulting\Connections\Events\ConnectionPermissionsChanged;
use RoundlyConsulting\Connections\Events\ConnectionInvited;   // a pending connection was created
use RoundlyConsulting\Connections\Events\ConnectionAccepted;  // status → accepted
use RoundlyConsulting\Connections\Events\ConnectionBlocked;   // status → blocked
use RoundlyConsulting\Connections\Events\ConnectionRestored;  // a soft-deleted link was restored
use RoundlyConsulting\Connections\Events\ConnectionExpiring;  // dispatched by notify-expiring
```

| Event | Fired when | Payload |
| --- | --- | --- |
| `ConnectionCreated` | A new connection is created, or a soft-deleted pair is revived fresh — connect, invite, grant/sync on a missing pair, bulk and sync attaches. | `$connection` |
| `ConnectionUpdated` | connect() changes an existing pair, or extend() changes the expiry. | `$connection` |
| `ConnectionRemoved` | disconnect(), disconnectAll() or a sync detach soft-deletes a connection. | `$connection` |
| `ConnectionPermissionsChanged` | grant, revoke, sync or clear actually changes an existing set. | `$connection, $previous, $current` |
| `ConnectionInvited` | A new connection is created in the pending state. | `$connection` |
| `ConnectionAccepted` | The status changes to accepted. | `$connection` |
| `ConnectionBlocked` | The status changes to blocked. | `$connection` |
| `ConnectionRestored` | reconnect() / restore() / reconnectTo() restores a soft-deleted row, or connect() restores a soft-deleted blocked pair still blocked. | `$connection` |
| `ConnectionExpiring` | connections:notify-expiring runs — one event per row of Connections::expiring($days). | `$connection, $daysUntilExpiry` |

Lean on these events for auditing and notifications — the package ships no audit table. For example, listeners that log acceptances and diff permission changes:

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Connections\Events\ConnectionAccepted;
use RoundlyConsulting\Connections\Events\ConnectionPermissionsChanged;

// In a service provider's boot() method.
Event::listen(function (ConnectionAccepted $event): void {
    logger()->info('Connection accepted', ['connection' => $event->connection->id]);
});

Event::listen(function (ConnectionPermissionsChanged $event): void {
    $added = array_diff($event->current, $event->previous);
    $removed = array_diff($event->previous, $event->current);

    // write $added / $removed to your own audit log
});
```

- connections:prune soft-deletes expired rows in a single query, so it dispatches no ConnectionRemoved events.
- Bulk verbs and syncConnections() still fire one event per affected connection.
- Set events.enabled to false to silence every package event, including ConnectionExpiring.
- Every write event — all but ConnectionExpiring — implements ShouldDispatchAfterCommit: outside a transaction it fires at once; inside one (a bulk connectAll() or sync(), or your own DB::transaction()) it waits for the commit and is dropped on rollback, so a listener never hears about a row that doesn’t exist. ConnectionExpiring writes nothing and dispatches immediately.

## 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/connections-for-laravel.md)
