Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Naoray/nova-json into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 7, 2021
2 parents 25e4528 + ad15520 commit 6d41f08
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# nova-json
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Total Downloads](https://img.shields.io/packagist/dt/naoray/nova-json.svg?style=flat-square)](https://packagist.org/packages/naoray/nova-json)

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.

```php
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.

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


## Install
`composer require naoray/nova-json`

Expand Down Expand Up @@ -47,4 +64,4 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
If you discover any security-related issues, please email krishan.koenig@googlemail.com instead of using the issue tracker.

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

0 comments on commit 6d41f08

Please sign in to comment.