Search by

roundly-consulting / contacts-for-laravel

mihaliak

Store and query contacts for any entity or category in a Laravel application.

Package info

github.com/roundly-consulting/contacts-for-laravel

pkg:composer/roundly-consulting/contacts-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 23

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 18:10 UTC

This package is auto-updated.

Last update: 2026-10-03 18:31:03 UTC


README

Contacts for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Contacts for Laravel

Typed, validated contacts for any Laravel model — emails, phones, addresses, URLs, social handles and custom kinds on a user, company or order. Values are normalized before they are stored, every owner keeps one primary per kind, and contacts can be verified with a code and exported as vCard.

Installation

Requires PHP 8.4, Laravel 12 or 13.

composer require roundly-consulting/contacts-for-laravel
php artisan vendor:publish --tag="addresses-migrations"
php artisan vendor:publish --tag="connections-migrations"
php artisan vendor:publish --tag="contacts-migrations"
php artisan migrate

If your owner models have UUID/ULID keys, set CONTACTS_KEY_TYPE before migrating.

Usage

Add HasContacts to any model:

use RoundlyConsulting\Contacts\Concerns\HasContacts;

class User extends Model
{
    use HasContacts;
}

Add, read and export contacts through the facade:

use RoundlyConsulting\Contacts\Enums\ContactType;
use RoundlyConsulting\Contacts\Facades\Contacts;

Contacts::for($user)->email(' A.Person@Example.COM ')->label('Work')->primary()->add();
Contacts::for($user)->phone('+421 900 000 000')->label('Mobile')->add();

Contacts::for($user)->primary(ContactType::Email)?->value;   // 'a.person@example.com'
Contacts::for($user)->ofType(ContactType::Phone);              // ordered by position
Contacts::for($user)->vCard();                                 // a vCard 3.0 string

Verify a contact — the package issues the code, your app delivers it:

use RoundlyConsulting\Contacts\Events\ContactVerificationRequested;

Event::listen(function (ContactVerificationRequested $event): void {
    // send $event->plainToken to $event->contact->value by SMS or mail
});

$phone = Contacts::for($user)->primary(ContactType::Phone);

Contacts::verification()->request($phone);          // a 6-digit code, stored only as a hash
Contacts::verification()->confirm($phone, $code);   // sets verified_at, or throws

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/contacts-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

The MIT License (MIT). See LICENSE.md for details.