Laravel在显示用户模板中获取图像

时间:2017-11-14 08:21:24

标签: laravel

我正在尝试从/users/show.blade.php访问我的图像表。我在控制器中有这个...

if ( (firstCount = secondCount) and (secondCount = thirdCount) and (firstCount = ThirdCount) )
  return true;
else
  return false;

当我尝试在模板中使用$ my_images变量时,我得到$ my_images的未定义变量错误

我哪里错了?

1 个答案:

答案 0 :(得分:2)

你应该试试这个:

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')); 
}

您在刀片文件中将$my_images名称作为image传递,以获取此错误。