---
title: "Metadata — Connections for Laravel | Roundly"
description: "Attach free-form context to a connection in a JSON meta bag, read it with dot access, and merge or replace it on re-connect."
url: https://roundly-consulting.com/open-source/docs/connections-for-laravel/metadata
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)

# Metadata

Attach free-form context — who invited whom, a role label, an import source — to a connection’s JSON meta column, with no side table to maintain:

```php
Connections::between($user, $team)
    ->withMeta(['invited_by' => $admin->id, 'role' => ['label' => 'owner']])
    ->connect();

$connection->meta('role.label');           // 'owner' (dot access)
$connection->meta('missing', 'fallback');  // 'fallback'

// Re-connecting merges meta by default; replaceMeta() overwrites instead.
Connections::between($user, $team)->withMeta(['note' => 'hi'])->connect();          // merge; perms + expiry kept
Connections::between($user, $team)->withMeta(['note' => 'hi'])->replaceMeta()->connect();

// The trait verb takes meta too.
$user->connectTo($team, ['view'], now()->addMonth(), ['source' => 'import']);
```

- meta($key, $default) reads with dot notation and returns the default when the key is missing.
- Re-connecting merges the staged meta over the stored meta at the top level — permissions and expiry are kept; replaceMeta() overwrites the meta instead.
- A connect() without withMeta() leaves the stored meta untouched.
- withMeta() can be called several times on one builder — each call merges into the staged bag.
- connectAll() — which honours replaceMeta() — and SyncTarget items passed to sync() accept meta too.
- The raw meta attribute is the full array, or null when nothing was stored.

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