Passing data from controller to view in Laravel

前端 未结 9 1761
我在风中等你
我在风中等你 2020-11-30 10:26

I am new to laravel and I have been trying to store all records of table \'student\' to a variable and then pass that variable to a view so that I can display them.

9条回答
  •  再見小時候
    2020-11-30 10:44

    You can try this as well:

    public function showstudents(){
       $students = DB::table('student')->get();
       return view("user/regprofile", ['students'=>$students]);
    }
    

    Also, use this variable in your view.blade file to get students name and other columns:

    {{$students['name']}}
    

提交回复
热议问题