Answer the question
In order to leave comments, you need to log in
How to correctly execute a request with a json field in Laravel?
there is a value of the rates column in the format:
[{"rate": "1", "price": "500"}, {"rate": "2", "price": "1000"}, {"rate": "3", "price": "1500"}]
Answer the question
In order to leave comments, you need to log in
do json_decode() now you have php array.
Next, iterate over this very array using foreach, well, then you check and do what you need
This is not even about laravel. You at the level of the database will not be able to filter normally like this.
As far as I know, in the latest versions of mysql (okay, not so straight in the latest ones, since 5.7), json support has appeared and even filtering by json elements. But it works terribly slowly. (this is not accurate)
If possible, change the structure of the database - do not store in json, use a separate table and a one-to-many relationship for this.
If not, then you have to do as Maxim Fix suggested .
Well, another variant, if the database is fresh, then you can try like this: JSON Where Clauses
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question