LARAVEL::如何在另一个刀片页面上显示请求的日期范围



我有一个函数,它从我的刀片表单中请求start dateEnd date,然后它从该日期范围中查找报告

所以我想在第二页的顶部显示那些日期范围start dateEnd date

控制器

public function stockIssued(Request $request) {
$startdate=$request->startdate;
$enddate=$request->enddate;
//issued
$stockIssued=DB::select(DB::raw(" SELECT 
products.id, 
products.name,  
(select ifnull(sum(loadings.qty),0) from loadings where loadings.pid=products.id and 
DATE(loadings.created_at)  BETWEEN STR_TO_DATE('$startdate','%m/%d/%Y') AND 
STR_TO_DATE('$enddate','%m/%d/%Y')  ) as total_loadings_specific_date
from products"));
$pdf = PDF::loadView('report.issuedreportprint',compact('stockIssued'));
return $pdf->download('issuedreport.pdf'); 
// return view('report.issuedreport',compact('stockIssued'));
//
}

刀片视图(我想在报告顶部显示这些日期(

</head>
<body>
<?php
$startdate = $request->old('startdate');
$enddate = $request->old('enddate');
echo "<p>From:'$startdate'  To:'$enddate'</p>"
?>
<table  width="90%" border="1"  align="center" style="margin-top: 20px;margin-bottom: 2px; margin- 
left:10px; margin-right:10px; " >
<thead>
<tr>
<th>Items Name</th>
<th>Total Qty</th>
</tr>
</thead>
<tbody>
@foreach($stockIssued as $dt)
<tr>
<td>{{$dt->name}}</td>
<td>{{$dt->total_loadings_specific_date ??0 }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

根据我的理解,如果你想将日期传递给你正在生成的pdf文件,你可以这样做:

$startdate = $request->startdate;
$enddate = $request->enddate;
$pdf = PDF::loadView('report.issuedreportprint',compact('stockIssued', 'startdate', 'enddate'));

然后在刀片文件中,您可以直接访问它:

<p> From:{{ $startdate }}  To: {{ $enddate }} </p>

最新更新