Support the ongoing development of Laravel.io →
Laravel

blade file code:

<tbody> @foreach ($Data as $item) <tr> <td>{{asset($item->image)}}</td> <td>{{$item->name}}</td> <td>{{$item->father_name}}</td> <td>{{$item->gender}}</td> <td>{{$item->reg_no}}</td> <td>{{$item->department}}</td> <td>{{$item->email}}</td> <td>{{$item->phone_no}}</td> <td class="action"> <a href="">Update</a> <a href="">Delete</a> </td> </tr> @endforeach </tbody>

Controller function code: public function showMembers(){ $member = Member::all(); return view('Dashboard')->with(['Data' => $member]); }

here i face a error "Undefined variable $Data" i do all the necessary troubleshoot with the help of chatgpt but still faceing same error please help.

Last updated by @anonymous4codes 1 year ago.
0

In your controller you can use:

$member=Member::all();
return view('Dashboard', ['data' => $member]);

or

$data=Member::all();
return view('Dashboard', compact('data'));

and make sure your view name is correct and also your variable $data in your view blade is same as it's in controller.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.