What is the best way in Laravel to store an array in your database? And how do I get the same array with a query?
I have a variable that's an array in an array:
$colors = array(array('green'), array('yellow', 'white'));
When I store $colors, my database (column type = json) save it as:
[["green"], ["yellow", "white"]]
But when I try to get it from a query, I couldn't get the same array as $colors.
My query:
$colors = DB::table('colors')
->where('id', '1')
->value('arraycolors');
I hope someone can help how to query an array. Thanks a lot!