{"id":50741819,"url":"https://github.com/whilesmartphp/eloquent-contacts","last_synced_at":"2026-06-10T18:00:30.715Z","repository":{"id":363852137,"uuid":"1265244471","full_name":"whilesmartphp/eloquent-contacts","owner":"whilesmartphp","description":"Polymorphic contacts (people attached to customers, vendors, anything) for Laravel.","archived":false,"fork":false,"pushed_at":"2026-06-10T16:36:57.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-10T17:20:49.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whilesmartphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-10T15:42:23.000Z","updated_at":"2026-06-10T16:35:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-contacts","commit_stats":null,"previous_names":["whilesmartphp/eloquent-contacts"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-contacts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-contacts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-contacts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-contacts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-contacts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-contacts/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-contacts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34163252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-10T18:00:21.351Z","updated_at":"2026-06-10T18:00:30.681Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# whilesmart/eloquent-contacts\n\nPolymorphic contacts for Laravel: people (with name, email, phone, title) attached to any\nmodel, scoped to an owner through\n[`whilesmart/eloquent-owner-access`](https://github.com/whilesmartphp/eloquent-owner-access).\nAn org customer with several people, a vendor with an AP desk, anything with humans behind it.\n\n## Install\n\n```\ncomposer require whilesmart/eloquent-contacts\nphp artisan migrate\n```\n\nRoutes register automatically under the `api` prefix with `auth:sanctum`. Set\n`CONTACTS_REGISTER_ROUTES=false` to mount them yourself.\n\n## Attaching contacts to a model\n\n```php\nuse Whilesmart\\Contacts\\Traits\\HasContacts;\n\nclass Customer extends Model\n{\n    use HasContacts;\n}\n\n$customer-\u003econtacts()-\u003ecreate([\n    'owner_type' =\u003e Workspace::class,\n    'owner_id' =\u003e $workspaceId,\n    'first_name' =\u003e 'Jane',\n    'last_name' =\u003e 'Doe',\n    'email' =\u003e 'ap@acme.test',\n    'title' =\u003e 'Accounts Payable',\n    'address' =\u003e '12 Market St, Douala',\n    'is_primary' =\u003e true,\n]);\n\n$customer-\u003eprimaryContact?-\u003eemail;       // recipient for billing\n$customer-\u003eprimaryContact?-\u003efull_name;   // \"Jane Doe\"\n```\n\n`contacts()` returns every contact; `primaryContact()` returns the one flagged primary. Only\none contact per parent can be primary: setting `is_primary` on one demotes the others\nautomatically.\n\n## Custom model\n\nThe Contact model is swappable. Publish the config and point `contacts.model` at your own\nclass (extend the package model to add fields/casts/behaviour):\n\n```php\n// config/contacts.php\n'model' =\u003e \\App\\Models\\Contact::class,\n```\n\nThe trait relations, route binding, and controller all resolve the class from config, so your\nmodel is used everywhere.\n\n## UUID keys\n\nOff by default (auto-incrementing integer ids). To use UUID primary keys, set `CONTACTS_UUIDS=true`\n(or `contacts.uuids` config) **before running the migration**. The migration then creates a\n`uuid` primary key and `uuid` morph columns, and the model generates an ordered UUID on create.\nThis assumes the owner and contactable models also use UUID keys.\n\n## Endpoints\n\n| Method | Path | Purpose |\n|--------|------|---------|\n| GET | `/api/contacts` | List (filter by `owner_*`, `contactable_type` + `contactable_id`, `q`) |\n| POST | `/api/contacts` | Create |\n| GET | `/api/contacts/{contact}` | Show |\n| PUT/PATCH | `/api/contacts/{contact}` | Update |\n| DELETE | `/api/contacts/{contact}` | Soft delete |\n\nList a single parent's people with\n`/api/contacts?contactable_type=App\\Models\\Customer\u0026contactable_id=42`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-contacts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-contacts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-contacts/lists"}