So in Laravel 5 there's the handy thing called JSON Where Clauses using MySQL's new ability to store and fetch JSON stored in a column:
User::where('meta->colors', 'red')->get()
would return all rows, where colors
in the column meta
would be set to red
.
现在假设colors
不是一个字符串,而是一个包含多种 colored颜色 的数组(colors => ['red', 'blue', 'green']
).
What would be an efficient way to retrieve all rows, where colors
contains e.g. the value red
?