---
title: "Toggle, reconnect & restore — Connections for Laravel | Roundly"
description: "Disconnect with soft deletes, flip a connection with toggle(), and bring a removed one back as it was with reconnect() or fresh with connect()."
url: https://roundly-consulting.com/open-source/docs/connections-for-laravel/toggle-reconnect
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)

# Toggle, reconnect & restore

disconnect() soft-deletes the connection and fires ConnectionRemoved; it throws ConnectionNotFound when there is none. The trashed row keeps its place in the unique pair index, so a disconnected pair is always revived in place — never inserted twice:

```php
Connections::between($user, $team)->disconnect();   // soft delete, fires ConnectionRemoved
$user->disconnectFrom($team);                        // the trait equivalent
```

## Toggle, reconnect and restore

```php
// Disconnect an active connection, otherwise connect — as often as you like. Over a pending,
// blocked or expired row the "connect" keeps that status and expiry (it never lifts a block
// or renews an expiry — use accept() / extend() for that).
Connections::between($user, $team)->toggle();   // ?Connection
$user->toggleConnection($team);

// Restore a previously soft-deleted connection with the permissions, expiry and meta it had
// (connect() would start it fresh), firing ConnectionRestored — or connect afresh if none trashed.
Connections::between($user, $team)->reconnect();
Connections::between($user, $team)->restore();  // alias
$user->reconnectTo($team);
```

- toggle() disconnects an active connection and returns null; otherwise it connects and returns the Connection — as often as you like. toggleConnection() is the trait method and accepts permissions.
- The active check follows enforce\_active\_on\_check, so a pending, blocked or expired connection counts as not connected. toggle() then connects over it but keeps that status and expiry — it never lifts a block or renews an expiry; use accept() or extend() for that.
- Switching a pair back on after a toggle-off revives the soft-deleted row as a fresh connection.
- reconnect() restores the soft-deleted row with the permissions, expiry and meta it had and fires ConnectionRestored. When nothing is trashed it connects afresh and fires ConnectionCreated instead. restore() is an alias; reconnectTo() is the trait method.

## Restore it, or start over

After a disconnect() or a prune you choose how the pair comes back: reconnect() restores the old connection, connect() — like grant(), permissions()->sync(), invite(), toggle() and sync() — revives the row as a fresh connection with only what you stage plus the config defaults. A blocked pair stays blocked either way:

```php
Connections::between($user, $team)->disconnect();

// Restore it as it was — permissions, expiry and meta (ConnectionRestored).
Connections::between($user, $team)->reconnect();

// Or start over: connect() revives the soft-deleted row as a fresh connection (ConnectionCreated),
// with what you stage plus the config defaults — a blocked pair is restored still blocked.
Connections::between($user, $team)->withPermissions('view')->connect();
```

## Restored as it was

A restored connection comes back exactly as it was — permissions, status, meta and expiry included. Connections soft-deleted by connections:prune can be restored too, but their expiry is still in the past, so renew it:

```php
Connections::between($user, $team)->disconnect();

// Later — bring the same connection back, then renew a lapsed expiry.
Connections::between($user, $team)->reconnect();
Connections::between($user, $team)->extend(now()->addMonth());
```

## 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)
