Store and query contacts for any entity or category in a Laravel application.
roundly-consulting/contacts-for-laravel is a Laravel package for store and query contacts for any entity or category in a laravel application..
It currently has 5 GitHub stars and 127 downloads on Packagist (latest version 1.1.2).
Install it with composer require roundly-consulting/contacts-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
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.
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.
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(' [email protected] ')->label('Work')->primary()->add();
Contacts::for($user)->phone('+421 900 000 000')->label('Mobile')->add();
Contacts::for($user)->primary(ContactType::Email)?->value; // '[email protected]'
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
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.
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.
The MIT License (MIT). See LICENSE.md for details.