Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/en/docs/field.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,21 @@ Matrix::make('users')
]),
```

Data in DB will be stored in JSON format, and once retrived must be casted as an associative array, you can do something like this in your model to do the job:

```php
use Illuminate\Database\Eloquent\Casts\Attribute;
...
protected function users(): Attribute
{
return Attribute::make(
get: fn ($value) => json_decode($value, true),
set: fn ($value) => json_encode($value),
);
}

```

> **Note.** The matrix under the hood does the copying of the fields on the client side. This works fine for simple `input/select/etc` fields, but may not work well for complex or compound fields.

## Code editor
Expand Down