Let's say I have this Laravel Eloquent model:
$scores = [];
$dataScores = Book::where('author_id', '=', $uid)
->select('score')
->get();
Which results in:
[{
"score": 30
},
{
"score": 100
},
{
"score": 17
},
{
"score": 75
},
{
"score": 17
},
{
"score": 0
},
{
"score": 60
},
{
"score": 100
},
{
"score": 17
},
{
"score": 67
},
{
"score": 83
},
{
"score": 50
},
{
"score": 100
},
{
"score": 50
},
{
"score": 83
},
{
"score": 38
},
{
"score": 90
},
{
"score": 10
},
{
"score": 83
},
{
"score": 83
},
{
"score": 60
},
{
"score": 80
},
{
"score": 13
},
{
"score": 33
},
{
"score": 33
}]
So, I figure before I return the view(), I would do this:
for ($s=0; $s < count($dataScores); $s++) {
array_push($scores, $dataScores[$s]->score);
}
return view(
'layouts.dashboard.main',
[
'menu' => 'book-dashboard',
'scores' => $scores
]
);
So, I would just access {{ $scores }} in the Laravel Blade view and I thought I would get
$scores = [
30,
100,
17,
75,
17,
0,
60,
100,
17,
67,
83,
50,
100,
50,
83,
38,
90,
10,
83,
83,
60,
80,
13,
33,
33
];
But instead I get:
htmlspecialchars() expects parameter 1 to be string, array given.
But If I include the before-modified array of just the key/value of score / x.. then it returns fine. I just want the score values in an array.