In Laravel how to sort database records in json object?

0 like 0 dislike
218 views
Friends, good afternoon.
Can you please tell me the way to solve the following situation (Laravel):
There is a table rows:
id name
And there is a table rows_user_sort:
user_id sort
this string lies a json object c row.id and sort - order number for sorting:
[{"id": 244, "sort": 0}, {"id": 4, "sort": 1}, {"id": 20, "sort": 2}, {"id": 21, "sort": 3}, {"id": 22, "sort": 4}, {"id": 15, "sort": 5}, {"id": 24, "sort": 6}]

How to sort rows by a similar json object?
Thanks in advance.
by | 218 views

1 Answer

0 like 0 dislike
that's what's stopping You rows_user_sort to make {user_id, row_id,sort_weight} ?
Now sort in PHP code, the array results
or assemble an sql query with order by find_in_set()
by

Related questions

0 like 0 dislike
1 answer
asked Apr 9, 2019 by anonymanon
0 like 0 dislike
1 answer
0 like 0 dislike
5 answers
0 like 0 dislike
2 answers
asked May 2, 2019 by GrozInventor
110,608 questions
257,187 answers
0 comments
40,796 users