I
I
Ivan2019-03-16 14:35:59
Laravel
Ivan, 2019-03-16 14:35:59

How to link jsonb field to other tables?

The site has the ability to save the search,
when saving, the user id and json query string are written to the table, for example

{  
   "advert_status":1,
   "filter_models":{  
      "type_id":1,
      "adventure_state":1
   },
   "additionally_filter":{  
      "currency_id":1
   }
}

The task is to link, for example, filter_models->type_id by id with the types table through a one-to-one relationship

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2019-03-16
@vhuk1802

Look towards https://github.com/staudenmeir/eloquent-json-relations . In one of the projects, we set up connections like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question