A
A
Alexey Sklyarov2020-12-07 14:34:54
Laravel
Alexey Sklyarov, 2020-12-07 14:34:54

How to properly organize the work of custom fields with nesting?

It required the introduction of custom fields for certain models, in a specific case - for posts. But I would like to have some kind of field structure, in this case it is already known and understandable:

custom_fields : {
  category_field: {
    field_name: value,
    field_name: value
  },
  category_field: {
    field_name: value,
    field_name: value
  },
  category_field: {
    field_name: value,
    field_name: value
  }
}


I looked at examples of the implementation of custom fields, came across this solution . I liked that all fields can be stored in one column of the table as json. But what about additional nesting? The first thing that comes to mind is to write, according to that guide, a similar structure:

$article->updateMeta('field_category.field_name', 'A fantastic value');


Are there any examples of implementing nested custom fields?

Framework: Laravel 8.0
DB: PostgreSQL

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanes, 2020-12-07
@Sanes

Discover table relationships .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question