---
title: "Affiliations & relationships — Contacts for Laravel | Roundly"
description: "Link contacts to each other and to owners — works at, spouse of — with invitations, expiry and an optional allow-list of relationship kinds."
url: https://roundly-consulting.com/open-source/docs/contacts-for-laravel/relationships
language: en
---

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

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

# Affiliations & relationships

A Contact is Connectable through connections-for-laravel. Link contacts to each other and to owners with a free-form, config-driven relationship kind:

```php
$person->connectTo($company, ['employee']);       // raw connection
$person->relateTo($company, 'works_at');           // typed kind, stored in meta
$person->relationsOfKind('works_at');              // contacts related under a kind
$person->inviteConnection($company);               // pending -> accept/block
$company->acceptConnectionFrom($person);

Contacts::sharedWith($owner);                       // contacts connected to an owner
```

- relateTo(Connectable $other, string $kind, array $meta = \[\]) — stores the kind in the connection’s meta, merged over any extra meta you pass. Relating twice is idempotent.
- relationsOfKind(string $kind) — the contacts this contact is related to under that kind. Like the connections listing helpers, it counts only active relationships while connections.enforce\_active\_on\_check is on (the default): blocked, pending and expired ones are left out. Turn the flag off to list them too.
- Relating a contact to itself throws RelationshipException.
- Contacts::sharedWith($owner) — contacts connected to an owner, so one shared contact (a supplier, say) can belong to many owners without duplication. The owner must be Connectable.

## Connections API

The full connections API is available on every contact — invitations, blocking, expiry and removal:

```php
$person->relateTo($company, 'works_at', ['since' => '2024-03']);  // extra meta
$person->relateTo($company, 'works_at');   // idempotent — still one edge

$person->connectTo($consultant, ['contractor'], now()->addDays(30));  // expiring edge
$person->expiringConnections();            // edges expiring within 7 days
$person->disconnectFrom($consultant);
$company->blockConnectionFrom($person);
```

## Restricting relationship kinds

Restrict the allowed kinds with contacts.relationship\_kinds. Relating under any other kind throws RelationshipException:

```php
// config/contacts.php — empty = free-form; a list or a kind => label map restricts kinds
'relationship_kinds' => [
    'works_at' => 'Works at',
    'spouse_of' => 'Spouse of',
    'reports_to' => 'Reports to',
],
```

Soft-deleting a contact trashes its relationship edges in both directions, restore() brings them back and forceDelete() removes them for good.

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