{"id":21504416,"url":"https://github.com/dcasia/nova-json-wrapper","last_synced_at":"2026-03-13T17:40:54.320Z","repository":{"id":46129874,"uuid":"215177132","full_name":"dcasia/nova-json-wrapper","owner":"dcasia","description":"Allows you to group Nova fields and merge their output into a single JSON column","archived":false,"fork":false,"pushed_at":"2024-10-25T06:44:57.000Z","size":296,"stargazers_count":13,"open_issues_count":7,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T19:18:43.512Z","etag":null,"topics":["json","json-wrapper","laravel","laravel-nova-field","nova"],"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/dcasia.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2019-10-15T01:21:09.000Z","updated_at":"2023-04-10T23:46:47.000Z","dependencies_parsed_at":"2025-01-01T12:11:44.736Z","dependency_job_id":"82845514-4089-4de0-9027-43c8504ded73","html_url":"https://github.com/dcasia/nova-json-wrapper","commit_stats":{"total_commits":12,"total_committers":5,"mean_commits":2.4,"dds":"0.41666666666666663","last_synced_commit":"db092d70aef022b2e0a895bc092dde361723193e"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fnova-json-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fnova-json-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fnova-json-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcasia%2Fnova-json-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcasia","download_url":"https://codeload.github.com/dcasia/nova-json-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094990,"owners_count":21046770,"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":["json","json-wrapper","laravel","laravel-nova-field","nova"],"created_at":"2024-11-23T18:59:43.504Z","updated_at":"2026-03-13T17:40:49.301Z","avatar_url":"https://github.com/dcasia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nova Json Wrapper\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/digital-creative/nova-json-wrapper)](https://packagist.org/packages/digital-creative/nova-json-wrapper)\n[![Total Downloads](https://img.shields.io/packagist/dt/digital-creative/nova-json-wrapper)](https://packagist.org/packages/digital-creative/nova-json-wrapper)\n[![License](https://img.shields.io/packagist/l/digital-creative/nova-json-wrapper)](https://github.com/dcasia/nova-json-wrapper/blob/master/LICENSE)\n\nThis field allows you to group Nova fields and merge their output into a single JSON column.\n\n# Installation\n\nYou can install the package via composer:\n\n```\ncomposer require digital-creative/nova-json-wrapper\n```\n\n## Usage\n\nFirstly you will need to update your model to cast the value of your attribute to an array:\n\n```php\nclass User extends Model\n{\n    protected $casts = [\n        'options' =\u003e 'array'\n    ];\n}\n```\n\nThen create a `JsonWrapper` field within your nova resource and use the `HasJsonWrapper` trait.\n\n```php\n\nuse DigitalCreative\\JsonWrapper\\JsonWrapper;\nuse DigitalCreative\\JsonWrapper\\HasJsonWrapper;\n\nclass User extends Resource\n{\n    use HasJsonWrapper; // Important!\n\n    public function fields(Request $request)\n    {\n        //...\n        JsonWrapper::make('options', [\n\n            Text::make('First Name')-\u003erules('required'),\n            Text::make('Last Name')-\u003erules('required'),\n\n            JsonWrapper::make('body_mass', [\n\n                Text::make('Weight')-\u003erules('required'),\n                Text::make('Height')-\u003erules('required'),\n\n            ])\n\n        ])\n    }\n\n}\n\n```\n\nThis converts to\n\n```json\n{ \"first_name\": \"John\", \"last_name\": \"Doe\", \"body_mass\": { \"weight\": 70, \"height\": 180 } }\n```\n\nand saves to the `options` column on the database.\n\n## Notes\n\nThere are no visual indications that the field is wrapped within a json, this is intentional. It was designed to work\nin condition with [Conditional Container](https://github.com/dcasia/conditional-container) allowing to seamlessly\ncreate complex data structure and having it all saved in a single json column into your database, here is an full example:\n\n```php\npublic function fields(Request $request)\n{\n    Select::make('Type')\n          -\u003eoptions([\n              1, 2, 3, 4, 5\n          ])\n          -\u003erules('required'),\n\n    ConditionalContainer::make([\n\n        JsonWrapper::make('data', [\n\n            Text::make('First Name')-\u003erules('required'),\n            Text::make('Last Name')-\u003erules('required'),\n\n            Select::make('Gender')\n                  -\u003eoptions([\n                      'male' =\u003e 'Male',\n                      'female' =\u003e 'Female'\n                  ])\n                  -\u003erules('required'),\n\n            ConditionalContainer::make([ JsonWrapper::make('extra', [ ... ]) ])-\u003eif('gender === male'),\n            ConditionalContainer::make([ JsonWrapper::make('extra', [ ... ]) ])-\u003eif('gender === female'),\n\n        ])\n\n    ])-\u003eif('type \u003e= 2'),\n}\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://raw.githubusercontent.com/dcasia/nova-json-wrapper/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcasia%2Fnova-json-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcasia%2Fnova-json-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcasia%2Fnova-json-wrapper/lists"}