{"id":28476640,"url":"https://github.com/armincms/json","last_synced_at":"2025-07-02T16:31:42.721Z","repository":{"id":62487627,"uuid":"224601158","full_name":"armincms/json","owner":"armincms","description":"A laravel nova field","archived":false,"fork":false,"pushed_at":"2020-06-18T04:02:57.000Z","size":22,"stargazers_count":26,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T15:07:22.752Z","etag":null,"topics":["json","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/armincms.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-28T08:06:18.000Z","updated_at":"2024-07-14T17:00:17.000Z","dependencies_parsed_at":"2022-11-02T10:46:58.671Z","dependency_job_id":null,"html_url":"https://github.com/armincms/json","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/armincms/json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armincms%2Fjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armincms%2Fjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armincms%2Fjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armincms%2Fjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/armincms","download_url":"https://codeload.github.com/armincms/json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armincms%2Fjson/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263175486,"owners_count":23425581,"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","laravel-nova-field","nova"],"created_at":"2025-06-07T15:07:23.191Z","updated_at":"2025-07-02T16:31:42.710Z","avatar_url":"https://github.com/armincms.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json\nA laravel nova field \n\n##### Table of Contents   \n* [Install](#install)      \n* [Usage](#usage)       \n* [Nested Usage](#nested-usage)       \n* [Action Usage](#action-usage)       \n* [Showing / Hiding Fields](#showing-and-hiding-fields)       \n* [Last Values](#last-values)       \n* [Separated Data](#separated-data)       \n* [Fill The Value](#fill-the-value)  \n* [Null Values](#null-values) \n* [Auto Casting](#auto-casting)  \n* [About Implementation](#about-implementation)    \n\n## Install\n```bash\ncomposer require armincms/json\n``` \n  \n## Usage \nSo simple.\n\n``` \n\n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n      Select::make(__(\"Discount Type\"), \"type\")\n          -\u003eoptions([\n              'percent' =\u003e __('Percent'),\n              'amount' =\u003e __('Amount'),\n          ])-\u003erules('required')-\u003edefault('percent'),\n      Number::make(__(\"Discount Value\"), \"value\")\n          -\u003erules(\"min:0\")\n          -\u003ewithMeta([\n              'min' =\u003e 0\n          ]),   \n  ]),\n\n```\n\n## Nested Usage \nStoring nested data is very like straight data. just like the following; use the `Json` nested.\n\n\n```  \n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n      Select::make(__(\"Discount Type\"), \"type\")\n          -\u003eoptions([\n              'percent' =\u003e __('Percent'),\n              'amount' =\u003e __('Amount'),\n          ])-\u003erules('required')-\u003edefault('percent'),\n      Number::make(__(\"Discount Value\"), \"value\")\n          -\u003erules(\"min:0\")\n          -\u003ewithMeta([\n              'min' =\u003e 0\n          ]),   \n      // nested data\n      Json::make(\"discount\", [ \n        Select::make(__(\"Discount Type\"), \"type\")\n            -\u003eoptions([\n                'percent' =\u003e __('Percent'),\n                'amount' =\u003e __('Amount'),\n            ])-\u003erules('required')-\u003edefault('percent'),\n        Number::make(__(\"Discount Value\"), \"value\")\n            -\u003erules(\"min:0\")\n            -\u003ewithMeta([\n                'min' =\u003e 0\n            ]),   \n      ]),\n  ]),\n\n```\n\n## Action Usage \nIt is possible to use the `Json` in the `Action` like follow:\n\n\n\n```  \nuse Armincms\\Json\\Json;\n\nclass UpdateTime extends Action\n{\n    use InteractsWithQueue, Queueable, SerializesModels; \n\n\n    /**\n     * Perform the action on the given models.\n     *\n     * @param  \\Laravel\\Nova\\Fields\\ActionFields  $fields\n     * @param  \\Illuminate\\Support\\Collection  $models\n     * @return mixed\n     */\n    public function handle(ActionFields $fields, Collection $models)\n    {\n      //\n    }\n\n\n    /**\n     * Get the fields available on the action.\n     *\n     * @return array\n     */\n    public function fields()\n    {\n        return collect([\n            /// some fields\n            \n            Json::make(mb_strtolower($meal), [\n                Text::make(__(\"From\"), 'from')-\u003erules('required'),\n                Text::make(__(\"Until\"), 'until')-\u003erules('required'),  \n                Json::make(mb_strtolower($meal), [\n                    Text::make(__(\"From\"), 'from'),\n                    Text::make(__(\"Until\"), 'until'),  \n                ]),\n            ]),\n\n            /// some fields\n        ])-\u003emap(function($field) {\n            return $field instanceof Json ? $field-\u003efields() : [$field];\n        })-\u003eflatten()-\u003eall();\n    }\n}\n\n\n```\n## Showing And Hiding Fields\nyou can use the field `show/hide` methods on the JSON field. so this method will be called on each field under the `Json` field.The following example will hide all fields from the `index` view.\n\n\n```  \n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n       // fields\n  ])-\u003ehideFromIndex(),\n\n``` \n\n\n## Save Last Values \nBy default; we clean the last data for store new data. but, it's possible to save the last data. for this, call the `saveHistory`  method on parent `Json` class. this causes us to overwrite the new data without clean the last data. see the follow:\n\n\n```  \n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n       // fields\n  ])-\u003esaveHistory(),\n\n``` \n\n## Separated Data\nIf you want store fields in one column but show in a separate place; you should make multiple `Json` field by one name.see the following:\n\n```  \n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n       // fields group 1\n  ]),\n\n  // other feilds\n\n\n  Json::make(\"ColumnName\", [ \n       // fields group 2\n  ])-\u003esaveHistory(),\n\n``` \n\n\n* ATTENTION: at this situation, you should use `saveHistory` for next `Json` field. \n\n\n## Fill The Value\nif you want to store the customized value of the field; you can use the `fillUsing` \nmethod and return custom value. see the follow:\n\n* `fillUsing` accept three argumnets `$request`, `$attribute`, `$requestAttribute`.\n\n```  \n  use Armincms\\Json\\Json;  \n  \n\n  Json::make(\"ColumnName\", [ \n       Number::make(__(\"Discount Value\"), \"value\")\n            -\u003erules(\"min:0\")\n            -\u003ewithMeta([\n                'min' =\u003e 0\n            ])-\u003efillUsing(function($request, $attribute, $requestAttribute) {\n                if($request-\u003eexists($requestAttribute)) { \n                    return $request[$requestAttribute];\n                }\n\n                return 1000;\n            }), \n  ]),\n  \n```\n\n## Null Values\nIf there need to store some values as the `null`; you can use the `nullable` method that works like the Nova nullable. \nBy default; nullable has the `true` value which means all values will be stored. But; It's possible to reject the storing of null values via passing the `false` value into the `nullable` method.\n\n## Auto Casting\nIf not defined JSON casting for the field attribute; we will convert the field Value into JSON.\nif you need disable this feature; use the `ignoreCasting` method;\n\n## About Implementation\nMaybe there exists a question about how this package works? \n\nI Should say that; this package doesn't have any corresponds component to the `Vuejs`. \nthis package just uses `callback`'s for data storing. so; won't changed any field.\n\nwith this implementation, you have access to your original fields without changes.\nSo; for interacts with other packages or fields, exists `toArray` method to access to defined fields.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmincms%2Fjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmincms%2Fjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmincms%2Fjson/lists"}