@coder72 you can do it quite cleanly with just a foreach:
function attendancePerformance()
{
$students = Student::get();
$data = [];
$data[] = ["Students", "Present Day"];
foreach ($students as $student) {
$data[] = [$student->name, $student->present];
}
return $data;
}
you do get numeric keys with the returned data but that'd be fine if all you are doing is passing these to blade to display
I would also suggest you look at
$students = Student::all()->pluck('name','present');
as (if I am correct) this will return you a list of students name and present field.