Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store Model data as json? #81

Open
eminos opened this issue Sep 22, 2017 · 1 comment
Open

Store Model data as json? #81

eminos opened this issue Sep 22, 2017 · 1 comment

Comments

@eminos
Copy link

eminos commented Sep 22, 2017

Is there a way to store data for a model as nested json, in one db column?

%fieldset
    .legend Other
    != Former::text('content.section1.heading')
    != Former::text('content.section1.lead')
    != Former::text('content.section2.heading')
    != Former::text('content.section2.lead')

I have a bunch of fields for a model, but not really many enough to qualify for a related model.

@eminos
Copy link
Author

eminos commented Sep 22, 2017

I think I figured it out.

%fieldset
    .legend Section 1
    != Former::text('content[section1][heading]')
    != Former::text('content[section1][body]')

And then on the model:

protected $casts = [
    'content' => 'array',
];

Seems to work fine.

Maybe this should be in the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant