I'm trying to pass a list of names into the labels section of a Chart.js chart which I'm retrieving from a database with PHP.
In my controller I do
json_encode(array_pluck($var->toArray(), 'name'));
which returns:
"["name1","name2","name3","name4","name5","name6"]"
In the view, I have:
labels: {{ $var }},
and when I view the source, I can see
"name1","name2","name3","name4","name5","name6"
This is causing the chart to fail as it's expecting:
'name1','name2','name3','name4','name5','name6'
I've tried various things such as html_entity_decode
, json_decode
and htmlspecialchars_decode
but not of them seem to do anything.