mercredi 27 mai 2020

Laravel pass value from foreach loop in controller to view

I am trying to get the data from a foreach loop in my controller to pass to my view. How do I do it?

Controller

class FormteachersController extends Controller
{
    public function form_teachers_view(){
        $UniqueStudent = Student::where('Student_ClassID','JSS 1C')->get();
        foreach ($UniqueStudent as $keydata) {
            $student = $keydata->Stud_id;
            $result= Result::where('Term_ID','1st Term')->where('Student_ID',$student)->where('Class_ID','JSS 1C')->where('Session_ID','2225/2222')->get();
            foreach ($result as $keyresult) {
                echo '<br>'.'<br>'.$student.'-'.$result;
            }
            return view('teachers.form_teachers_comment_sec');
        }
    }
}

This is the output.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire