Download the PHP package whilesmart/eloquent-contacts without Composer
On this page you can find all versions of the php package whilesmart/eloquent-contacts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whilesmart/eloquent-contacts
More information about whilesmart/eloquent-contacts
Files in whilesmart/eloquent-contacts
Package eloquent-contacts
Short Description Polymorphic contacts (people attached to customers, vendors, anything) for Laravel applications.
License MIT
Informations about the package eloquent-contacts
whilesmart/eloquent-contacts
Polymorphic contacts for Laravel: people (with name, email, phone, title) attached to any
model, scoped to an owner through
whilesmart/eloquent-owner-access.
An org customer with several people, a vendor with an AP desk, anything with humans behind it.
Install
Routes register automatically under the api prefix with auth:sanctum. Set
CONTACTS_REGISTER_ROUTES=false to mount them yourself.
Applications can keep package-owned routes while replacing only the behavior they need:
The custom resource extends the package resource. The response formatter implements the package contract and receives the complete response payload and status code. The custom controller can extend the package controller as a final escape hatch. Write middleware applies to create, update, and delete actions that remain enabled.
Attaching contacts to a model
contacts() returns every contact; primaryContact() returns the one flagged primary. Only
one contact per parent can be primary: setting is_primary on one demotes the others
automatically.
Custom model
The Contact model is swappable. Publish the config and point contacts.model at your own
class (extend the package model to add fields/casts/behaviour):
The trait relations, route binding, and controller all resolve the class from config, so your model is used everywhere.
UUID keys
Off by default (auto-incrementing integer ids). To use UUID primary keys, set CONTACTS_UUIDS=true
(or contacts.uuids config) before running the migration. The migration then creates a
uuid primary key and uuid morph columns, and the model generates an ordered UUID on create.
This assumes the owner and contactable models also use UUID keys.
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /api/contacts |
List (filter by owner_*, contactable_type + contactable_id, q) |
| POST | /api/contacts |
Create |
| GET | /api/contacts/{contact} |
Show |
| PUT/PATCH | /api/contacts/{contact} |
Update |
| DELETE | /api/contacts/{contact} |
Soft delete |
List a single parent's people with
/api/contacts?contactable_type=App\Models\Customer&contactable_id=42.
All versions of eloquent-contacts with dependencies
laravel/framework Version ^11.0|^12.0
whilesmart/eloquent-owner-access Version ^1.0