PHPackages                             masterix21/laravel-contacts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. masterix21/laravel-contacts

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

masterix21/laravel-contacts
===========================

Add contacts book abilities to any Laravel project

1.0.0(2mo ago)0147MITPHPPHP ^8.2CI passing

Since Sep 23Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/masterix21/laravel-contacts)[ Packagist](https://packagist.org/packages/masterix21/laravel-contacts)[ Docs](https://github.com/masterix21/laravel-contacts)[ GitHub Sponsors](https://github.com/LucaLongo)[ RSS](/packages/masterix21-laravel-contacts/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (26)Versions (14)Used By (0)

Laravel Contacts
================

[](#laravel-contacts)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bd482d4b4f89f173dd63a2d273393a8c84e379abf65fe848f3f3eebbab208ab6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173746572697832312f6c61726176656c2d636f6e74616374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-contacts)[![Tests](https://camo.githubusercontent.com/111beae05aa7eea9b2dd8de74bff2411fe87108433cf45464e61b459a77eb85c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173746572697832312f6c61726176656c2d636f6e74616374732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/masterix21/laravel-contacts/actions?query=workflow%3Arun-tests+branch%3Amain)[![PHPStan](https://camo.githubusercontent.com/beddb787cb589520d911f89ba334c02bb0c00cffe8c537b8feb2b13c2bbe2a1f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173746572697832312f6c61726176656c2d636f6e74616374732f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/masterix21/laravel-contacts/actions?query=workflow%3APHPStan+branch%3Amain)[![Code Style](https://camo.githubusercontent.com/6f8b6683b1f18b91353420ca29e4d5e70a4081dfbb93846abd61dd8f4f43d398/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173746572697832312f6c61726176656c2d636f6e74616374732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/masterix21/laravel-contacts/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/fdc8e425d6806ed2524b12ff1932e2ad2e672935dbcdd04c4067fb57194452c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173746572697832312f6c61726176656c2d636f6e74616374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-contacts)

Attach a contact book to any Eloquent model. Users, companies, venues, projects — anything that needs phone numbers, emails, websites, or social handles can grow them through a single polymorphic relation, without you spinning up a dedicated table for every model.

Why
---

[](#why)

Most apps end up scattering contact fields across half a dozen tables: a `phone` column on `users`, an `email` on `companies`, a separate `addresses` table that nobody trusts. This package centralises all of that into one `contacts` table and lets any model attach as many entries as it needs.

A single contact row can hold a label (e.g. *Office*, *Personal*), a phone, a mobile, an email, a website, a few social handles, a push token, and a freeform `meta` JSON payload for anything else.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12, or 13

Installation
------------

[](#installation)

Install via Composer:

```
composer require masterix21/laravel-contacts
```

Publish and run the migration:

```
php artisan vendor:publish --tag="laravel-contacts-migrations"
php artisan migrate
```

If you need to swap the `Contact` model for your own subclass, publish the config:

```
php artisan vendor:publish --tag="laravel-contacts-config"
```

```
// config/contacts.php
return [
    'models' => [
        'contact' => \App\Models\Contact::class,
    ],
];
```

Usage
-----

[](#usage)

Add the `HasContacts` trait to any model that should own contacts:

```
use Illuminate\Database\Eloquent\Model;
use LucaLongo\LaravelContacts\Models\Concerns\HasContacts;

class User extends Model
{
    use HasContacts;
}
```

That's it — the model now exposes a polymorphic `contacts()` relation plus four filtered helpers.

### Adding contacts

[](#adding-contacts)

```
$user->contacts()->create([
    'label' => 'Office',
    'email' => 'luca@example.com',
    'phone' => '+39 02 1234567',
    'website' => 'https://example.com',
]);

$user->contacts()->create([
    'label' => 'Personal',
    'mobile' => '+39 333 1234567',
    'meta' => [
        'preferred_channel' => 'whatsapp',
        'timezone' => 'Europe/Rome',
    ],
]);
```

### Reading contacts

[](#reading-contacts)

The trait ships with helpers that filter the relation by the field you care about:

```
$user->contacts;   // every contact
$user->emails;     // only contacts with a non-null email
$user->phones;     // only contacts with a non-null phone
$user->mobiles;    // only contacts with a non-null mobile
$user->websites;   // only contacts with a non-null website
```

Each helper returns a `MorphMany`, so you can keep chaining:

```
$primaryEmail = $user->emails()->where('label', 'Office')->first()?->email;
```

### The meta field

[](#the-meta-field)

`meta` is cast to `AsArrayObject`, so you can read and write it like a native array and Laravel will persist the JSON for you:

```
$contact = $user->contacts()->first();

$contact->meta['preferred_channel'] = 'email';
$contact->save();
```

### Available fields

[](#available-fields)

FieldTypeNotes`label`stringFree label, e.g. *Office*, *Billing*`phone`, `mobile`stringLandline / mobile numbers`email`string`website`string`facebook`, `x`, `linkedin`stringSocial handles or full URLs`push_token`stringDevice push token`meta`arrayAnything else, stored as JSONThe model has no `$fillable` and `$guarded = []`, so mass-assignment is open by design — guard your input at the request layer.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md) for the release history.

Contributing
------------

[](#contributing)

See [CONTRIBUTING](CONTRIBUTING.md).

Security
--------

[](#security)

Found a vulnerability? Please review the [security policy](../../security/policy) before opening a public issue.

Credits
-------

[](#credits)

- [Luca Longo](https://github.com/masterix21)
- [All contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Recently: every ~145 days

Total

7

Last Release

65d ago

Major Versions

0.0.6 → 1.0.02026-04-29

PHP version history (2 changes)0.0.1PHP ^8.2

0.0.5PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/177020fc4adb5c08acee3e6fe0b65002a96665c5d5c522a3ef009b4105fd634f?d=identicon)[masterix](/maintainers/masterix)

---

Top Contributors

[![masterix21](https://avatars.githubusercontent.com/u/6555012?v=4)](https://github.com/masterix21 "masterix21 (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelLucaLongolaravel-contacts

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/masterix21-laravel-contacts/health.svg)

```
[![Health](https://phpackages.com/badges/masterix21-laravel-contacts/health.svg)](https://phpackages.com/packages/masterix21-laravel-contacts)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)[tapp/filament-form-builder

User facing form builder using Filament components

132.4k3](/packages/tapp-filament-form-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
