[英]array don't view in blade template laravel
$udata = DB::table('student_info')
->join('student_academy', 'student_info.student_id', '=', 'student_academy.student_id')
->where('student_info.student_id', $id)
->where('student_academy.student_id', $id)
->get();
dd($udata); dd($ udata); ---> Here is ok.
--->可以。 and i tried 3 way:
我尝试了3种方式:
return view('pages.student.editStudent', compact('udata')); 返回视图('pages.student.editStudent',compact('udata'));
return view('pages.student.editStudent', ['udata'=> $udata]); 返回视图('pages.student.editStudent',['udata'=> $ udata]);
return view('pages.student.editStudent')->with('udata', $udata ); 返回view('pages.student.editStudent')-> with('udata',$ udata);
But every time Display this error 但是每次显示此错误
(2/2) ErrorException Property [s_name] does not exist on this collection instance. (2/2)ErrorException属性[s_name]在此集合实例上不存在。
where is my mistake ?? 我的错误在哪里?
try this way.. 尝试这种方式..
@foreach($udata as $data)
{{$data->s_name}}
@endforeach
or
{{$udata[0]->s_name}}
改用{{udata[0]['s_name']}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.