本文介绍了如何修复未定义的变量:Laravel中domPDF中的合作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将使用domPDF打印PDF.这是我的 CollaboPDFController.php:
I am going to print PDF using domPDF. this is My CollaboPDFController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use PDF;
use App\Collaboration;
class CollaboPDFController extends Controller
{
public function getPDF(){
$collaborators = Collaboration::all();
$pdf = PDF::loadView('collaborators.form',['Collaborators'=>$collaborators]);
return $pdf->stream('form.collaborators');
}
//
}
这是我要以pdf文件格式打印的刀片视图"巫婆.这是collaborators文件夹中的form.blade.php文件.
and this is My blade view witch I am going to print as pdf file. it is form.blade.php file in collaborators folder.
<div class="col-md-4" style="border:1px solid #ccc;margin-left:15px;padding:10px;">
<h4 class="page-header">
Collaborators
</h4>
@if($collaborators)
@foreach( $collaborators as $collaborator)
<div>
<div>
<span>
<img src="{{ $collaborator->user()->first()->getAvatarUrl() }}" />
{{ $collaborator->user()->first()->username}}
{{ $collaborator->user()->first()->id}}
</span>
</div>
推荐答案
据我所知,变量区分大小写,请尝试替换['Collaborators'=>$collaborators]
到['collaborators'=>$collaborators]
As far as I know, variables are case-sensitive, try to replace['Collaborators'=>$collaborators]
to ['collaborators'=>$collaborators]
这篇关于如何修复未定义的变量:Laravel中domPDF中的合作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!