PHPackages                             gabrielesbaiz/nova-field-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. gabrielesbaiz/nova-field-json

ActiveLibrary

gabrielesbaiz/nova-field-json
=============================

Customer Nova field for JSON data.

1.0.0(1y ago)02.4k↑550%MITPHPPHP ^8.0CI passing

Since Mar 3Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/gabrielesbaiz/nova-field-json)[ Packagist](https://packagist.org/packages/gabrielesbaiz/nova-field-json)[ Docs](https://github.com/gabrielesbaiz/nova-field-json)[ GitHub Sponsors]()[ RSS](/packages/gabrielesbaiz-nova-field-json/feed)WikiDiscussions main Synced 1mo ago

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

NovaFieldJson
=============

[](#novafieldjson)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a0b59084f2d327b65fa410c5893329e9751c3fd99d4a5c7f6859def6c7d5a418/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6761627269656c65736261697a2f6e6f76612d6669656c642d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gabrielesbaiz/nova-field-json)[![Total Downloads](https://camo.githubusercontent.com/58888e61f5a37658f7a522db423834ab92454636b72101470bf839f05744eba1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6761627269656c65736261697a2f6e6f76612d6669656c642d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gabrielesbaiz/nova-field-json)

Customer Nova field for JSON data.

Original code from [armincms/json](https://github.com/armincms/json)

Features
--------

[](#features)

- ✅ Advanced Json support
- ✅ Basic usage
- ✅ Nested usage
- ✅ Action usage
- ✅ Showing / Hiding fields
- ✅ Save last values
- ✅ Separated data
- ✅ Fillable values
- ✅ Null values
- ✅ Autocasting

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require gabrielesbaiz/nova-field-json
```

Usage
-----

[](#usage)

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
      Select::make(__("Discount Type"), "type")
          ->options([
              'percent' => __('Percent'),
              'amount' => __('Amount'),
          ])->rules('required')->default('percent'),
      Number::make(__("Discount Value"), "value")
          ->rules("min:0")
          ->withMeta([
              'min' => 0
          ]),
  ]),
```

### Nested Usage

[](#nested-usage)

Storing nested data is very like straight data. just like the following; use the `Json` nested.

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
      Select::make(__("Discount Type"), "type")
          ->options([
              'percent' => __('Percent'),
              'amount' => __('Amount'),
          ])->rules('required')->default('percent'),
      Number::make(__("Discount Value"), "value")
          ->rules("min:0")
          ->withMeta([
              'min' => 0
          ]),
      // nested data
      NovaFieldJson::make("discount", [
        Select::make(__("Discount Type"), "type")
            ->options([
                'percent' => __('Percent'),
                'amount' => __('Amount'),
            ])->rules('required')->default('percent'),
        Number::make(__("Discount Value"), "value")
            ->rules("min:0")
            ->withMeta([
                'min' => 0
            ]),
      ]),
  ]),
```

### Action Usage

[](#action-usage)

It is possible to use the `Json` in the `Action` like follow:

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

class UpdateTime extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
      //
    }

    /**
     * Get the fields available on the action.
     *
     * @return array
     */
    public function fields()
    {
        return collect([
            /// some fields

            NovaFieldJson::make(mb_strtolower($meal), [
                Text::make(__("From"), 'from')->rules('required'),
                Text::make(__("Until"), 'until')->rules('required'),
                NovaFieldJson::make(mb_strtolower($meal), [
                    Text::make(__("From"), 'from'),
                    Text::make(__("Until"), 'until'),
                ]),
            ]),

            /// some fields
        ])->map(function($field) {
            return $field instanceof NovaFieldJson ? $field->fields() : [$field];
        })->flatten()->all();
    }
}
```

### Showing And Hiding Fields

[](#showing-and-hiding-fields)

you 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.

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
       // fields
  ])->hideFromIndex(),
```

### Save Last Values

[](#save-last-values)

By 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:

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
       // fields
  ])->saveHistory(),
```

### Separated Data

[](#separated-data)

If 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:

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
       // fields group 1
  ]),

  // other fields

  NovaFieldJson::make("ColumnName", [
       // fields group 2
  ])->saveHistory(),
```

- ATTENTION: at this situation, you should use `saveHistory` for next `Json` field.

### Fill The Value

[](#fill-the-value)

if you want to store the customized value of the field; you can use the `fillUsing`method and return custom value. see the follow:

- `fillUsing` accept three argumnets `$request`, `$attribute`, `$requestAttribute`.

```
use Gabrielesbaiz\NovaFieldJson\NovaFieldJson;

  NovaFieldJson::make("ColumnName", [
       Number::make(__("Discount Value"), "value")
            ->rules("min:0")
            ->withMeta([
                'min' => 0
            ])->fillUsing(function($request, $attribute, $requestAttribute) {
                if($request->exists($requestAttribute)) {
                    return $request[$requestAttribute];
                }

                return 1000;
            }),
  ]),

```

### Null Values

[](#null-values)

If there need to store some values as the `null`; you can use the `nullable` method that works like the Nova nullable. By 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.

### Auto Casting

[](#auto-casting)

If not defined JSON casting for the field attribute; we will convert the field Value into JSON. if you need disable this feature; use the `ignoreCasting` method;

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Armin Group](https://github.com/armincms)
- [Gabriele Sbaiz](https://github.com/gabrielesbaiz)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance47

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

442d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97040fb60637d4b81897347524bc9343ffa6b978d4b19c0c28ea0823e2a1752b?d=identicon)[gabrielesbaiz](/maintainers/gabrielesbaiz)

---

Top Contributors

[![gabrielesbaiz](https://avatars.githubusercontent.com/u/22818698?v=4)](https://github.com/gabrielesbaiz "gabrielesbaiz (3 commits)")

---

Tags

laravelGabriele Sbaiznova-field-json

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

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