I want to build a data variable containing the number of occurrences of unix datetime values.
i.e.
{1489140000.0: 2, 1487239200.0: 1, 1483524000.0: 2, 1486634400.0: 1, 1490086800.0: 3 }
My error is that on the view I'm getting laravel use of undefined constant datas - assumed 'datas'
public function showStatistics()
{
$job_post_date = Emploi::where('language', 'EN')->pluck('POSTDATE');
$unix_time = array();
for ($i=0; $i < count($job_post_date) ; $i++) {
$unix_time[$i] = strtotime($job_post_date[$i]);
}
$datas = array_count_values($unix_time);
$datas = json_encode($datas);
return view('emploi.stats', ['datas' => $datas]);
}
excerpt of a javascript part in the stats.blade.php
....
var cal = new CalHeatMap();
cal.init({
itemSelector: "#example-d",
domain: "month",
itemName: ["job", "jobs"],
data: {!! datas !!},
start: thisMonth.SubtractMonth(5),
cellSize: 12,
cellPadding: 5,
....
I'm getting an error in the template on: {{ datas }}