我使用dompdf生成一个pdf,其中包含我从控制器传输到视图的信息,但是我无法发送for循环中更改的数据
所以我要怎么做才能将该数据发送到pdf视图,我需要您的帮助 他有解决方案还是我将使用另一个库pdf
这是我的控制器
src="/static/js/jQuery.min.js"
那么我该怎么做才能将该数据发送到pdf视图
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Commande;
use Illuminate\Support\Facades\Input;
use PDF;
use App\Commercial;
use DB;
use App\Client;
use Illuminate\Support\Facades\Log;
class CommandeController extends Controller
{
//save data
public function store(Request $request)
{
//$checked=input::get('checked');
$nbrrowsol=$request->get('nbrrowsol');
$nbrroweau=$request->get('nbrroweau');
$nbrrowveg=$request->get('nbrrowveg');
$nbrrowbiof=$request->get('nbrrowbiof');
$nbrrowmic=$request->get('nbrrowmic');
$nbrrowrp=$request->get('nbrrowrp');
$nbrrowautres=$request->get('nbrrowautres');
//error_log('Some message here.');
if ( !empty ( $nbrrowsol ) ) {
for ($i=1; $i <=$nbrrowsol ; $i++) {
# code...
$commande=new Commande();
$commande->nom_client =$request->get('nomclient');
$commande->organisme =$request->get('organisme');
$commande->adresse =$request->get('adresse');
$commande->email =$request->get('email');
$commande->tel1 =$request->get('tel');
$commande->tel2 =$request->get('tel2');
$commande->fax =$request->get('fax');
$commande->commercial =$request->get('commercial');
$commande->date_reception =$request->get('datereception');
$commande->date_prelevement =$request->get('dateprelev');
$commande->saved_by =$request->get('savedby');
$commande->code =$request->get('codesol'.$i);
$commande->nature =$request->get('naturesol'.$i);
$commande->reference_cli =$request->get('reference_clisol'.$i);
$commande->profondeur =$request->get('profondeursol'.$i);
$commande->culture =$request->get('culturesol'.$i);
$commande->variete =$request->get('varietesol'.$i);
$commande->gps =$request->get('gpssol'.$i);
$commande->analyse_demande =$request->get('analysedemandesol'.$i);
$commande->valide =$request->get('checkvalidee');
$commande->save();
}
}
$clients = DB::table('clients')->where('nom',$request->get('nomclient'))->first();
$commercial=DB::table('commercials')->where('name',$request->get('commercial'))->first();
$datereception=$request->get('datereception');
$dateprelev=$request->get('dateprelev');
$nbrrowsol=$request->get('nbrrowsol');
$nbrroweau=$request->get('nbrroweau');
$nbrrowveg=$request->get('nbrrowveg');
$nbrrowbiof=$request->get('nbrrowbiof');
$nbrrowmic=$request->get('nbrrowmic');
$nbrrowrp=$request->get('nbrrowrp');
$nbrrowautres=$request->get('nbrrowautres');
$pdf=PDF::loadview('gestion_commandes.myPDF',['clients'=>$clients,'commercial'=>$commercial,'daterecep'=>$datereception,'dateprelev'=>$dateprelev,'nbrrowsol'=>$nbrrowsol,'nbrroweau'=>$nbrroweau,'nbrrowveg'=>$nbrrowveg,'nbrrowbiof'=>$nbrrowbiof,'nbrrowmic'=>$nbrrowmic,'nbrrowrp'=>$nbrrowrp,'nbrrowautres'=>$nbrrowautres])->setPaper('a4', 'landscape');
return $pdf->stream('hdtuto.pdf');
}
}
答案 0 :(得分:0)
您可以使用compact()函数:
$pdf = PDF::loadview('gestion_commandes.myPDF', compact('comande'));