{"id":13563456,"url":"https://github.com/dillingham/nova-attach-many","last_synced_at":"2025-04-08T04:14:52.697Z","repository":{"id":34074862,"uuid":"168799986","full_name":"dillingham/nova-attach-many","owner":"dillingham","description":"BelongsToMany create / edit form component for Nova","archived":false,"fork":false,"pushed_at":"2023-10-10T14:37:20.000Z","size":406,"stargazers_count":271,"open_issues_count":21,"forks_count":104,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-03-14T14:45:32.050Z","etag":null,"topics":["laravel","laravel-nova"],"latest_commit_sha":null,"homepage":"","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/dillingham.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-02T05:58:23.000Z","updated_at":"2024-02-23T20:56:23.000Z","dependencies_parsed_at":"2023-10-10T17:10:46.619Z","dependency_job_id":null,"html_url":"https://github.com/dillingham/nova-attach-many","commit_stats":{"total_commits":76,"total_committers":17,"mean_commits":4.470588235294118,"dds":0.6710526315789473,"last_synced_commit":"c06cf6b9b25e4fafe07d9f39cb48ac33c6f5884c"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-attach-many","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-attach-many/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-attach-many/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-attach-many/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dillingham","download_url":"https://codeload.github.com/dillingham/nova-attach-many/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["laravel","laravel-nova"],"created_at":"2024-08-01T13:01:19.483Z","updated_at":"2025-04-08T04:14:52.672Z","avatar_url":"https://github.com/dillingham.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Nova Attach Many\n\n[![Latest Version on Github](https://img.shields.io/github/release/dillingham/nova-attach-many.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-attach-many)\n[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-attach-many.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-attach-many) [![Twitter Follow](https://img.shields.io/twitter/follow/im_brian_d?color=%231da1f1\u0026label=Twitter\u0026logo=%231da1f1\u0026logoColor=%231da1f1\u0026style=flat-square)](https://twitter.com/im_brian_d)\n\nBelongs To Many create \u0026 edit form UI for Nova. Enables attaching relationships easily and includes validation.\n\n![attach-many](https://user-images.githubusercontent.com/29180903/52160651-be7fd580-2687-11e9-9ece-27332b3ce6bf.png)\n\n### Installation\n\n```bash\ncomposer require dillingham/nova-attach-many\n```\n\n### Usage\n\n```php\nuse NovaAttachMany\\AttachMany;\n```\n```php\npublic function fields(Request $request)\n{\n    return [\n        AttachMany::make('Permissions'),\n    ];\n}\n```\n\nYou can explicitly define the relationship \u0026 Nova resource:\n\n```php\nAttachMany::make('Field Name', 'relationshipName', RelatedResource::class);\n```\n\n### Display on detail:\n\nThis package only provides the create / edit views that BelongsToMany does not.\n\nBelongsToMany should be used for displaying the table on detail views.\n\n```php\npublic function fields(Request $request)\n{\n    return [\n        AttachMany::make('Permissions'),\n        BelongsToMany::make('Permissions'),\n    ];\n}\n```\n\n### Validation\n\nYou can set min, max, size or custom rule objects\n\n```php\n-\u003erules('min:5', 'max:10', 'size:10', new CustomRule)\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/29180903/52160802-9ee9ac80-2689-11e9-9657-80e3c0d83b27.png\" width=\"75%\" /\u003e\n\n\n### Options\n\nHere are a few customization options\n\n- `-\u003eshowCounts()` Shows \"selected/total\"\n- `-\u003eshowPreview()` Shows only selected\n- `-\u003ehideToolbar()` Removes search \u0026 select all\n- `-\u003eheight('500px')` Set custom height\n- `-\u003efullWidth()` Set to full width\n- `-\u003eshowRefresh()` Request the resources again\n- `-\u003eshowSubtitle()` Show the resource's subtitle\n- `-\u003ehelp('\u003cb\u003eTip:\u003c/b\u003e help text')` Set the help text\n\n### All Options Demo\n\u003cimg src=\"https://user-images.githubusercontent.com/29180903/53781117-6978ee80-3ed5-11e9-8da4-d2f2408f1ffb.png\" width=\"75%\"/\u003e\n\n### Relatable\nThe attachable resources will be filtered by relatableQuery()\nSo you can filter which resources are able to be attached\n\n### Being Notified of Changes\n\nYou can add a method to the resource to be notified of the changes that have happened:\n\nThe method must be a camel cased version of the attribute name, followed by `Synced`. For example:\n\n```php\npublic function fields(Request $request)\n{\n    return [\n        AttachMany::make('Permissions'),\n    ];\n}\n```\n\n```php\npublic function permissionsSynced(array $changes)\n{\n    $changes['attached']; // An array of IDs of attached models\n    $changes['detached']; // An array of IDs of detached models\n    $changes['updated']; // An array of IDs of updated models\n}\n```\n\n\n### Authorization\nThis field also respects policies: ie Role / Permission\n- RolePolicy: attachAnyPermission($user, $role)\n- RolePolicy: attachPermission($user, $role, $permission)\n- PermissionPolicy: viewAny($user)\n\n---\n\n# Author\n\nHi 👋, Im Brian D. I created this Nova package [and others](https://novapackages.com/collaborators/dillingham)\n\nHope you find it useful. Feel free to reach out with feedback.\n\nFollow me on twitter: [@im_brian_d](https://twitter.com/im_brian_d)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-attach-many","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdillingham%2Fnova-attach-many","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-attach-many/lists"}