I have this code
$days = [];
foreach ($list1 as &$day){
$pleads = \DB::table('leads')
->selectRaw('count(*)')
->whereColumn('owned_by_id', 'users.id')
->where('lead_source_id', 7)
->whereRaw("DATE(created_at) = '$day'");
$mleads = \DB::table('leads')
->selectRaw('count(*)')
->whereColumn('owned_by_id', 'users.id')
->where('lead_source_id', 3)
->whereRaw("DATE(created_at) = '$day'");
$aleads = \DB::table('leads')
->selectRaw('count(*)')
->whereColumn('owned_by_id', 'users.id')
->where('lead_source_id', 4)
->whereRaw("DATE(created_at) = '$day'");
$personalleads = \DB::table('users')
->where('id', $id) // User ID
->select('users.id')
->selectSub($pleads, 'pleads')
->selectSub($mleads, 'mleads')
->selectSub($aleads, 'aleads')
->get();
$days []= $performanceTable;
}
return $days;
the output is
[[{"userid":1,"pleads":2,"mleads":1,"aleads":1}],[{"userid":1,"pleads":2,"mleads":1,"aleads":1}]]
The question is how to parse this with jQuery to access the values
Or better how to output them like this with php directly so it's easier to parse them with jQuery in a single array
[{"userid":1,"pleads":2,"mleads":1,"aleads":1},{"userid":1,"pleads":0,"mleads":0,"aleads":0}]
header('Content-Type: application/json');