Download the PHP package masterix21/laravel-contacts without Composer
On this page you can find all versions of the php package masterix21/laravel-contacts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download masterix21/laravel-contacts
More information about masterix21/laravel-contacts
Files in masterix21/laravel-contacts
Package laravel-contacts
Short Description Add contacts book abilities to any Laravel project
License MIT
Homepage https://github.com/masterix21/laravel-contacts
Informations about the package laravel-contacts
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
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
- PHP 8.2+
- Laravel 11, 12, or 13
Installation
Install via Composer:
Publish and run the migration:
If you need to swap the Contact model for your own subclass, publish the config:
Usage
Add the HasContacts trait to any model that should own contacts:
That's it — the model now exposes a polymorphic contacts() relation plus four filtered helpers.
Adding contacts
Reading contacts
The trait ships with helpers that filter the relation by the field you care about:
Each helper returns a MorphMany, so you can keep chaining:
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:
Available fields
| Field | Type | Notes |
|---|---|---|
label |
string | Free label, e.g. Office, Billing |
phone, mobile |
string | Landline / mobile numbers |
email |
string | |
website |
string | |
facebook, x, linkedin |
string | Social handles or full URLs |
push_token |
string | Device push token |
meta |
array | Anything else, stored as JSON |
The model has no $fillable and $guarded = [], so mass-assignment is open by design — guard your input at the request layer.
Testing
Changelog
See CHANGELOG for the release history.
Contributing
See CONTRIBUTING.
Security
Found a vulnerability? Please review the security policy before opening a public issue.
Credits
- Luca Longo
- All contributors
License
The MIT License (MIT). See LICENSE.md.
All versions of laravel-contacts with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16