How can I convert the format of an array from a Laravel Controller to JavaScript?
$data = DB::table('courses')
->selectRaw('courses.course_code,COUNT(student_applicants.status) as total')
->leftJoin('student_applicants', function ($join) {
$join->on('courses.id', '=', 'student_applicants.course_id')
->where('student_applicants.status', '=', 1)
->where('student_applicants.award_applied', '=', 1);
})
->groupBy('courses.course_code')
->pluck('total', 'c.course_code');
return view('admin.dashboard', ['data' => $data]);
I am aiming for the following format:
[
"BSA",
0
],
[
"BSBA-HR",
0
],
This is the current output in JavaScript and Laravel: