简体   繁体   中英

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); ---> Here is ok. and i tried 3 way:

  1. return view('pages.student.editStudent', compact('udata'));

  2. return view('pages.student.editStudent', ['udata'=> $udata]);

  3. return 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.

where is my mistake ??

try this way..

 @foreach($udata as $data)
    {{$data->s_name}}
    @endforeach

    or

{{$udata[0]->s_name}}

改用{{udata[0]['s_name']}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM