[英]LARAVEL::How to Display the requested date range on the another blade page
我有 function 从我的刀片表单中请求start date
和End date
,然后从该日期范围下载报告
所以我想在第二页的顶部显示这些日期范围的start date
和End date
。
CONTROLLER
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.