Reputation: 12568
I am trying to make my images table accessable from /users/show.blade.php. I have this in my controlller..
public function show($id)
{
/* Get All CSCS Images For User */
$my_images= Image::all();
/* Get User From ID */
$user = User::find($id);
/* Return View */
return view('users.show')->with('user', $user)->with('images', $my_images);
}
When I try and use the $my_images variable in my template I get an undefined variable error for $my_images
Where am I going wrong?
Upvotes: 1
Views: 52
Reputation: 21681
You should try this:
public function show($id)
{
/* Get All CSCS Images For User */
$my_images= Image::all();
/* Get User From ID */
$user = User::find($id);
/* Return View */
return view('users.show',compact('user','my_images'));
}
You pass $my_images
name as image
in your blade file for getting this error.
Upvotes: 2