Download the PHP package naoray/nova-json without Composer

On this page you can find all versions of the php package naoray/nova-json. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nova-json

nova-json

Total Downloads Tests

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.

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

Install & setup

composer require naoray/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

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

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.

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

When using data transfer objects (which works well with castable dto's) 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.

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

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

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

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

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

  1. JSON is the only field inside Panel

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

Testing

Run the tests with:

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


All versions of nova-json with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
illuminate/http Version ^9.0||^10.0||^11.0
illuminate/support Version ^9.0||^10.0||^11.0
laravel/nova Version ^3.0||^4.0
cakephp/chronos Version ^2.0||^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package naoray/nova-json contains the following files

Loading the files please wait ....