Reputation: 259
I need to get the record with special id and i have this in my method :
public function addedMark()
{
$user = Auth::user();
$subject = ClassSubject::where('teacher_id', $user->id)->pluck('id','subject_id');
return view('educator.account.marks', [
'user' => $user,
'marks' => StudentMark::where('subject_id', $subject)->get()
]);
}
When i do dd(ClassSubject::where('teacher_id', $user->id)->pluck('id','subject_id'));
i see that I'm getting the information that i need, but when i do dd(StudentMark::where('subject_id', $subject)->get());
it returns an empty array.
Any idea why?
Upvotes: 1
Views: 106
Reputation: 7421
Change it to (whereIn)
'marks' => StudentMark::whereIn('subject_id', $subject)->get()
and let see what hapens
Upvotes: 1
Reputation: 7313
In $subject
you have id
and subject_id
. You might wanna just take subject_id
.
So change this: StudentMark::where('subject_id', $subject)->get()
to
StudentMark::where('subject_id', $subject[1])->get()
Upvotes: 1