0
我打算使用domPDF來打印PDF。這是我的 CollaboPDFController.php:如何解決未定義變量:Laravel中domPDF中的協作者
<?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文件。它是協作者文件夾中的form.blade.php文件。
<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>
沒錯就是你是正確的問題 – Fernando