[英]how to retrieve PDF file from database into view using laravel 5.8?
Reade Me:读我:
Actually document is saved in database successfully but now i want to retrive it as pdf document and show in blade.php page.实际上文档已成功保存在数据库中,但现在我想将其检索为 pdf 文档并显示在blade.php 页面中。 Drivers are greater than 1 and each driver may has more than 1 documents驱动程序大于 1,每个驱动程序可能有 1 个以上的文档
driverlist.blade.php驱动程序列表.blade.php
<tbody>
@foreach ($drivers as $driver)
<tr>
<td>{{$driver->id}}</td>
<td>{{$driver->f_name}}</td>
<td>{{$driver->m_name}}</td>
<td>{{$driver->l_name}}</td>
<td>{{$driver->email}}</td>
<td>{{$driver->document}}</td> ==> here i am getting "null"
</tr>
@endforeach
</tbody>
CONTROLLER.PHP控制器.PHP
public function driver_list()
{
// dd("driver_list");
$drivers = Driver::all();
return view('admin/driverlist', compact('drivers'));
}
Logic while saving document保存文档时的逻辑
if ($file = $request->file('document'))
{
$name = $file->getClientOriginalName();
$destinationPath = public_path('/assets/docs/drivers');
$file->move($destinationPath, $name);
$driver->document= $name;
}
您可以使用任何 Laravel pdf 生成器包,例如:mpdf、dompdf ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.