我想在通过dompdf生成PDF的结果中显示数据库中的个人资料图片,但是结果是Image not found or type unknown
我的控制器
public function generatePDF(Request $request)
{
$id = Auth::user()->id;
$user = array(
"photo_url" => User::select("PHOTO_URL")->where("id", $id)->get()
)
$data["user"] = $user;
$pdf = PDF::loadView('generatePDF', $data);
return $pdf->stream('generatePDF.pdf');
我的观点
<img src="{{ asset('storage/imgprofile') . '/' . $user['photo_url'][0]['PHOTO_URL'] }}" width="220" height="220" alt="Profile Picture" />
答案 0 :(得分:0)
在您的控制器中:
User::select("PHOTO_URL")->where("id", $id)->get()
替换为:
User::find($id, ['PHOTO_URL'];
您认为:
<img src="{{ asset('storage/imgprofile') . '/' . $user->PHOTO_URL }}" width="220" height="220" alt="Profile Picture" />