{"id":21504446,"url":"https://github.com/dcasia/custom-relationship-field","last_synced_at":"2025-06-17T19:06:51.715Z","repository":{"id":50755109,"uuid":"235541239","full_name":"dcasia/custom-relationship-field","owner":"dcasia","description":"Emulate HasMany relationship without having a real relationship set between resources","archived":false,"fork":false,"pushed_at":"2024-07-18T12:26:48.000Z","size":672,"stargazers_count":33,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-24T16:23:15.972Z","etag":null,"topics":["custom-field","laravel","nova","nova4","relationship"],"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/dcasia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"milewski","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-01-22T09:40:26.000Z","updated_at":"2024-12-31T00:12:20.000Z","dependencies_parsed_at":"2023-09-25T02:53:43.466Z","dependency_job_id":"27de9fde-a737-4952-948e-dac67b49816a","html_url":"https://github.com/dcasia/custom-relationship-field","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":"0.23076923076923073","last_synced_commit":"b81a37e64e478ca5bd995845958b69f2f13a5b94"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/dcasia/custom-relationship-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fcustom-relationship-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fcustom-relationship-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fcustom-relationship-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fcustom-relationship-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcasia","download_url":"https://codeload.github.com/dcasia/custom-relationship-field/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fcustom-relationship-field/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260424782,"owners_count":23007044,"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":["custom-field","laravel","nova","nova4","relationship"],"created_at":"2024-11-23T19:00:19.984Z","updated_at":"2025-06-17T19:06:46.641Z","avatar_url":"https://github.com/dcasia.png","language":"PHP","funding_links":["https://github.com/sponsors/milewski"],"categories":[],"sub_categories":[],"readme":"# Custom Relationship Field\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/digital-creative/custom-relationship-field)](https://packagist.org/packages/digital-creative/custom-relationship-field)\n[![Total Downloads](https://img.shields.io/packagist/dt/digital-creative/custom-relationship-field)](https://packagist.org/packages/digital-creative/custom-relationship-field)\n[![License](https://img.shields.io/packagist/l/digital-creative/custom-relationship-field)](https://github.com/dcasia/custom-relationship-field/blob/main/LICENSE)\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/dcasia/custom-relationship-field/main/screenshots/dark.png\"\u003e\n  \u003cimg alt=\"Custom Relationship Field in action\" src=\"https://raw.githubusercontent.com/dcasia/custom-relationship-field/main/screenshots/light.png\"\u003e\n\u003c/picture\u003e\n\nThis field works just like as the default HasMany relationship field from nova but **without requiring a real relation** with the resource.\n\nThat means you are free to show resource `A` into the details page of resource `B` without having to create a real relation between them.\n\n# Installation\n\nYou can install the package via composer:\n\n```shell\ncomposer require digital-creative/custom-relationship-field\n```\n\n```php\nuse DigitalCreative\\CustomRelationshipField\\CustomRelationshipField;\nuse DigitalCreative\\CustomRelationshipField\\CustomRelationshipFieldTrait;\n\ntrait UserWithSimilarNameTrait\n{    \n    public static function similarNameQuery(NovaRequest $request, Builder $query, User $model): Builder\n    { \n        return $query-\u003ewhere('last_name', $model-\u003elast_name)-\u003ewhereKeyNot($model-\u003egetKey());\n    }\n    \n    public function similarNameFields(NovaRequest $request): array\n    {\n        return [\n            ID::make(),\n            Text::make('First Name'),\n            Text::make('Last Name'),\n        ];\n    }\n    \n    public function similarNameActions(NovaRequest $request): array \n    {\n        return [];\n    }\n\n    public function similarNameFilters(NovaRequest $request): array\n    {\n        return [];\n    }\n}\n\nclass User extends Resource\n{    \n    use CustomRelationshipFieldTrait;\n    use UserWithSimilarNameTrait;\n    \n    public function fields(NovaRequest $request): array\n    {\n        return [\n            ...\n            CustomRelationshipField::make('Users with similar name', 'similarName', User::class),\n            ...\n        ];\n    }\n}\n```\n\n## ⭐️ Show Your Support\n\nPlease give a ⭐️ if this project helped you!\n\n### Other Packages You Might Like\n\n- [Nova Dashboard](https://github.com/dcasia/nova-dashboard) - The missing dashboard for Laravel Nova!\n- [Nova Welcome Card](https://github.com/dcasia/nova-welcome-card) - A configurable version of the `Help card` that comes with Nova.\n- [Icon Action Toolbar](https://github.com/dcasia/icon-action-toolbar) - Replaces the default boring action menu with an inline row of icon-based actions.\n- [Expandable Table Row](https://github.com/dcasia/expandable-table-row) - Provides an easy way to append extra data to each row of your resource tables.\n- [Collapsible Resource Manager](https://github.com/dcasia/collapsible-resource-manager) - Provides an easy way to order and group your resources on the sidebar.\n- [Resource Navigation Tab](https://github.com/dcasia/resource-navigation-tab) - Organize your resource fields into tabs.\n- [Resource Navigation Link](https://github.com/dcasia/resource-navigation-link) - Create links to internal or external resources.\n- [Nova Mega Filter](https://github.com/dcasia/nova-mega-filter) - Display all your filters in a card instead of a tiny dropdown!\n- [Nova Pill Filter](https://github.com/dcasia/nova-pill-filter) - A Laravel Nova filter that renders into clickable pills.\n- [Nova Slider Filter](https://github.com/dcasia/nova-slider-filter) - A Laravel Nova filter for picking range between a min/max value.\n- [Nova Range Input Filter](https://github.com/dcasia/nova-range-input-filter) - A Laravel Nova range input filter.\n- [Nova FilePond](https://github.com/dcasia/nova-filepond) - A Nova field for uploading File, Image and Video using Filepond.\n- [Custom Relationship Field](https://github.com/dcasia/custom-relationship-field) - Emulate HasMany relationship without having a real relationship set between resources.\n- [Column Toggler](https://github.com/dcasia/column-toggler) - A Laravel Nova package that allows you to hide/show columns in the index view.\n- [Batch Edit Toolbar](https://github.com/dcasia/batch-edit-toolbar) - Allows you to update a single column of a resource all at once directly from the index page.\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://raw.githubusercontent.com/dcasia/custom-relationship-field/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcasia%2Fcustom-relationship-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcasia%2Fcustom-relationship-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcasia%2Fcustom-relationship-field/lists"}