PHPackages                             glacom/nova-json - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. glacom/nova-json

ActivePackage[Utility &amp; Helpers](/categories/utility)

glacom/nova-json
================

Nova json field to spread a json column throughout multiple fields.

1.1(2y ago)0435MITPHPPHP &gt;=8.0

Since May 31Pushed 2y agoCompare

[ Source](https://github.com/Glacom-Italia/GlacomJSON)[ Packagist](https://packagist.org/packages/glacom/nova-json)[ RSS](/packages/glacom-nova-json/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Nova JSON Field
===============

[](#nova-json-field)

[![Latest Version on Packagist](https://camo.githubusercontent.com/06def9caa69dc29a6ef93d74e7cc6145cddaf09551e5607efda5400042540c5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746570616e656e6b6f332f6e6f76612d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stepanenko3/nova-json)[![Total Downloads](https://camo.githubusercontent.com/7a6e8f0c331cd4b0f445704be9b2d17b93558419f06b6f2de342e401b14428ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746570616e656e6b6f332f6e6f76612d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stepanenko3/nova-json)[![License](https://camo.githubusercontent.com/68e2461b8c00168a05b53f4febf78cd06ccaaa9d9583d45b453b62940ab04d23/68747470733a2f2f706f7365722e707567782e6f72672f73746570616e656e6b6f332f6e6f76612d6a736f6e2f6c6963656e7365)](https://packagist.org/packages/stepanenko3/nova-json)

> This package is intended for the version of Laravel Nova 4, the original repository does not support Nova 4 at the time of creation, and the author does not accept PR Original repositrory for Nova 4

The `JSON` field wrapper allows you to specify multiple fields which will be resolved into a single model attribute. This allows you to validate every information you store inside a json column seperately.

```
JSON::make('Author', [
    Text::make('Name')->rules(['string', 'required', 'min:3']),
    Text::make('Email')->rules(['email', 'required']),
])
```

The above will be resolved into a single `author` attribute on the model.

```
// prequesite: the 'author' attribute needs to casted into a json castable type
// e.g. object, array, ...
['author' => ['name' => '', 'email' => '']]
```

Install &amp; setup
-------------------

[](#install--setup)

`composer require stepanenko3/nova-json`

Add the column's name, you want to use in the `JSON` field, to your `$casts` array on the resource's model!

Usage
-----

[](#usage)

- [Nova JSON Field](#nova-json-field)
    - [Install &amp; setup](#install--setup)
    - [Usage](#usage)
        - [FillUsing callbacks](#fillusing-callbacks)
        - [Fill at once](#fill-at-once)
        - [Nullable Fields](#nullable-fields)
        - [Labels and Attributes](#labels-and-attributes)
        - [Nested Structures](#nested-structures)
        - [Use inside Panels](#use-inside-panels)
            - [Examples](#examples)
    - [Changelog](#changelog)
    - [Contributing](#contributing)
    - [Credits](#credits)
    - [Security](#security)
    - [License](#license)

You can destructure one JSON column into multiple Nova fields and apply unique rules to each of the key-value pairs.

```
use Stepanenko3\NovaJson\JSON;

// within your nova resource
public function fields()
{
    return [
        //...
        JSON::make('Some Json Column Name', [
            Text::make('First Field'),
            Text::make('Second Field'),
            Text::make('Third Field'),
        ]);
    ]
}
```

### FillUsing callbacks

[](#fillusing-callbacks)

The `->fillUsing()` callbacks are normally used to fill the models attribute directly. With this package, it's not necessary to fill the model's attribute, but instead you should return the value you want to save on the model itself.

```
JSON::make('Address', 'address', [
    Text::make('Street')->fillUsing(fn ($request, $model, $attribute, $requestAttribute) => $request[$requestAttribute] . ' Foo'),
]);
```

The above example is rather silly than useful, but it demonstrates the concept. The \_ Foo\_ value will be apended to every `address->street` value within nova.

### Fill at once

[](#fill-at-once)

When using [data transfer objects](https://github.com/spatie/data-transfer-object) (which works well with [castable dto's](https://github.com/jessarcher/laravel-castable-data-transfer-object)) you don't want each field to be filled seperately, because than the dto's validation is useless. With the `fillAtOnce()` method a `Hidden` field will be added and the filling of single fields will be avoided. Instead all values will be filled at once via the `Hidden` field.

```
JSON::make('Address', 'address', [
    Text::make('Street'),
    Text::make('City'),
])->fillAtOnce();
```

The `fillOnce()` method accepts a `Callback` which can be used to modify the data structure before it is added to the model.

```
// given these fields:
JSON::make('Address', 'address', [
    Text::make('Street'),
    Text::make('City'),
])->fillAtOnce(function ($request, $requestValues, $model, $attribute, $requestAttribute) {
    return ['nested' => $requestValues];
});

// and a request with ['address->street' => 'test str. 5', 'address->city' => 'test city']

// we will get
$requestValues = ['street' => 'test str. 5', 'city' => 'test city'];

// which will be pased into the fillAtOnce callback leading to the following in our db:
['address' => ['nested' => ['street' => 'test str. 5', 'city' => 'test city']]];
```

### Nullable Fields

[](#nullable-fields)

As with other fields you can call `nullable()` and `nullValues()` on the JSON field directly to make all fields contained nullable and specify which values are treated as `null`

```
JSON::make('Address', 'address', [
    Text::make('Street'),
    Text::make('City'),
])->nullable()->nullValues(['_', 0])
```

### Labels and Attributes

[](#labels-and-attributes)

By default the first argument you provide the `JSON` field will be considered its `name`. If you don't provide a second string argument the `attribute` of the field will be guessed e.g. `'Some Json Column Name' => 'some_json_column_name'`. If you want your field `name` to be different from your `attribute` you can provide the field with a second argument and provide the fields as the third argument: `JSON::make('Some Name', 'column_name', [])`

### Nested Structures

[](#nested-structures)

The `JSON` field can also be nested by itself to display nested JSON structures:

```
JSON::make('Meta', [
    Text::make('Street'),

    JSON::make('Location', [
        Text::make('Latitude'),
        Text::make('Longitude'),
    ]),
]);
```

### Use inside Panels

[](#use-inside-panels)

In order to use JSON column inside Nova Panel you need to get 'data' property of the top level JSON field.

#### Examples

[](#examples)

1. JSON is the only field inside Panel

```
new Panel('Brand Settings',
    JSON::make('brand_settings', [
        Image::make('Logo')->disk('public'),
        Color::make('Primary Color')->swatches(),
        Color::make('Secondary Color')->swatches(),
    ]),
),
```

2. if you need other fields inside the Panel you can use splat operator like this:

```
new Panel('Brand Settings', [
    Text::make('Some Field'),
    JSON::make('brand_settings', [
        Image::make('Logo')->disk('public'),
        Color::make('Primary Color')->swatches(),
        Color::make('Secondary Color')->swatches(),
    ]),
]),
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Artem Stepanenko](https://github.com/stepanenko3)
- [Krishan Koenig](https://github.com/naoray)

Security
--------

[](#security)

If you discover any security-related issues, please using the issue tracker or pull requests.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1083d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba9e9d6ad279701a00460a2dc7308cc947154d09a021b2edd75d4c0348eb302f?d=identicon)[mattiaglacom](/maintainers/mattiaglacom)

![](https://www.gravatar.com/avatar/d5860f35582896b7a71446c90ff8a511c0ea3b858ebf78ce78000169b5fe518b?d=identicon)[iamousseni](/maintainers/iamousseni)

---

Tags

laravelnova

### Embed Badge

![Health badge](/badges/glacom-nova-json/health.svg)

```
[![Health](https://phpackages.com/badges/glacom-nova-json/health.svg)](https://phpackages.com/packages/glacom-nova-json)
```

###  Alternatives

[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2872.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2861.8M9](/packages/outl1ne-nova-sortable)[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3403.5M7](/packages/optimistdigital-nova-multiselect-field)[digital-creative/conditional-container

Provides an easy way to conditionally show and hide fields in your Nova resources.

116593.8k4](/packages/digital-creative-conditional-container)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

14720.0k](/packages/markwalet-nova-modal-response)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
