我是第一次接触Laravel,我一直在try 将表‘Student’的所有记录存储到一个变量中,然后将该变量传递给一个视图,这样我就可以显示它们了.
我有一个Controller-ProfileController,里面有一个函数:
public function showstudents() {
$students = DB::table('student')->get();
return View::make("user/regprofile")->with('students',$students);
}
In my view, I have this code:
<html>
<head>
//---HTML Head Part
</head>
<body>
Hi {{ Auth::user()->fullname }}
@foreach ($students as $student)
{{ $student->name }}
@endforeach
@stop
</body>
</html>
I am receiving this error: Undefined variable: students (View:regprofile.blade.php)