check whether student wrote the exam from two relationship table
guys iam working with a project online examination
i have two tables with relations
AssessmentTable with columns
id assmntname class_id chapter_id
StudentExamTable with columns
id assessment_id class_id section_id student_id
1 1 1 1 1
2 1 1 1 2
3 1 1 1 3
4 2 1 1 1
5 2 1 1 2
in the above table 1,2 assessments are there. student -1,2,3. assessment_id:1 written by all the three students. but ```assessment_id:2 not written by 3rd student.
how can i identify this is in blade file.
i have seperate logins for students.
when a student login. if there are 15 assessments and he wrote 5 assessments means . only 10 asssessments must be shown in his dashboard. if he wrote all the assessments then it must show no records
how to perform this?
i tried like this
$assessments = AssessmentCreationMain::with('studentexam')->get();
in my blade file
@foreach($assessments as $assessment)
@foreach($assessment->studentexam as $student)
@if($assessment->id==$student->assessment_id && $student->student_id==Auth::user()->id )
dont show the assessment
@else
show assessment
@endforeach
@endif
@endforeach
my Assessment Model
public function studentexam()
{
return $this->hasmany('App\StudentExam','assessment_id');
}
but i cant get it is there any easy way guys. some one help please
Please or to participate in this conversation.