where clause for prediction in laravel
I have 3 table
student (has many register)
score (NOT NULL)
semester (NOT NULL)
religion (NOT NULL)
program (has many register)
score(NULL)
semester(NULL)
religion(NULL)
register (belongsto many student and program)
student_id
program_id
I want to find a student who is predicted to pass the program without the user having to register the program first with this program. I know its a wrong condition in orWhere, but i have no idea to do it.
public function prediction($id)
{
$program = ReqProgram::find($id);
$student= Student::where(function($query) use($program){
$query ->where('score', '>=', $program->score)
->orWhere($program->score, '=', null;})
->where(function($query) use($program){
$query->where('religion', '=', $program->religion)
->orWhere($program->religion, '=', NULL);})
->where(function($query) use($program){
$query ->where('semester', '<=', $program->semester)
->orWhere($program->semester, '=', NULL);})
->get();
return view('kaprodi/prediction', compact(['student', 'program']));
}
I want to find students who have attributes that match the conditions. because table program attributes can be filled with NULL if user don't want to include those attributes as conditions, i dont know how to make it select student that not only, for example : student.score >= program.score, but if the program.score = null, and then the student will be selected as well. Is it possible? how can i do it? i been stuck so long
Please or to participate in this conversation.