Database 从数据库打印特定于Laravel的数据(图片)
我正在为Laravel使用DOMPDF包装器。我可以使用以下代码打印图像:Database 从数据库打印特定于Laravel的数据(图片),database,laravel,printing,Database,Laravel,Printing,我正在为Laravel使用DOMPDF包装器。我可以使用以下代码打印图像: public function print1() { $pdf = App::make('dompdf.wrapper'); $pdf->loadHTML('<img style="width:800px;height:1000px;" src="pic/m_cert.png">'); return $pdf->dow
public function print1()
{
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<img style="width:800px;height:1000px;" src="pic/m_cert.png">');
return $pdf->download('medcert.pdf');
}
这是我的钮扣
<a class="btn" href="{{ route('print_img',$user->user_info_id_number) }}">
Print
</a>
我检查了我的数据库,名称是正确的。我还输入了我的模型use\UserInfo
第二件事,我要如何在
return $pdf->download('user_img'.$user->user_info_id_number.'.pdf');
这行得通吗?UserInfo::find($id)如果通过执行以下操作将模型中的主键设置为id以外的其他值,则代码>作用于主键:
否则,可以在模型中设置其他关键点
protected $primaryKey = 'slug';
然后find将改为按该键进行搜索
Laravel还希望id为整数,如果您使用的不是整数(如字符串),则需要将模型上的incrementing属性设置为false:
public $incrementing = false;
哦,是的!我忘了!非常感谢你,伙计。。我又犯了一个错误。。找不到视图[]。我检查了路径和图像文件名是否正确
return $pdf->download('user_img'.$user->user_info_id_number.'.pdf');
protected $primaryKey = 'slug';
public $incrementing = false;