on the template $chart is an array..
in blade you can echo string only and blade will run htmlentities on every variable it's passed.
you can however do this on the template
<p class="chart">{{ json_encode($chart) }}</p>
You are producing an array, arrays are accessed via [], not via ->. So either you return an object from your calculateResult() method (e.g. with stdClass) or you simply use
{{ $chart['x'] }}
As far as I can see this has nothing to do with json whatsoever.
ftiersch said:
You are producing an array, arrays are accessed via [], not via ->. So either you return an object from your calculateResult() method (e.g. with stdClass) or you simply use
{{ $chart['x'] }}
As far as I can see this has nothing to do with json whatsoever.
After writing php for well over a decade i should of got that. Thanks ftiersch, now it makes sense. I'd based above on an eleoquent solution but wanted to run calcultions and render results. I'll convert my calculateResults class to return the data as an object.
In the end i just cast the array to an object in the Models return statement ie
return (object) $chart;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community