Level 60
what kind of problem?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to Export an Excel sheet but I have a problem with this line
$row[]=$student['student']['user']['en_name'];
This is the relation between user and student
public function user()
{
return $this->belongsTo(User::class,'user_id', 'id');
}
public function getStudentExposrtGrades($course)
{
//to get offering grade items heading grades
$courseModel=Course::find($course);
$columns=$courseModel->gradeItems()->pluck('grade_items.id')->toArray();
$query=[];
$courseStudentsGrades=CourseStudent::select('id','student_id','course_id')
->with('student:id,student_code','gradeItemCourses:id','student.user:id,en_name')
->where('course_id',$course)
->get()->toArray();
foreach($courseStudentsGrades as $student){
$row=[];
$row[]=$student['student']['student_code'];
$row[]=$student['student']['user']['en_name'];
$totalGrades=0;
$row[]=$student_grade;
}
}
return $query;
//dd($query);
}
Please or to participate in this conversation.