I have three classes Student, Session and student classes it has a relationship (Student with Enrollment, Session with Enrollment and student Class with enrollment), when I do echo it show the result [{"id":1,"school_id":1,"class_id":1,"student_id":1,"session_id":1,"created_at":null,"updated_at":null}] ,i have plucked value from student class
{{implode(',',$en->school()->get()->pluck('school_name')->toArray())}}
Note it is working
same from Session it is also working but when I plucked from student class and need class_name it not show an error but not the plucked value from studentclass here is the same type of query in blade.php
{{implode(',',$en->studentclass()->get()->pluck('class_name')->toArray())}}
here is the relationship one to many in StudentClass Controller
public function enrollments()
{
return $this->hasMany(Enrollement::class);
}
Enrollement Class
public function studentclass()
{
return $this->belongsTo(StudentClass::class);
}
how to pick the class_name value from table using this relationship. thanks