php - LARAVEL::如何在另一个刀片页面上显示请求的日期范围
问题描述
我有从我的刀片表单请求的功能start date
,End date
然后它从该日期范围下载报告
所以我想在第二页的顶部start date
显示这些日期范围。End 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>
推荐阅读
- php - 正则表达式匹配字符串以美元符号开头并包含 ( 并且没有空格或连字符
- nginx - 使用 vm 重写 Nginx 配置的规则
- asp.net-core - 无法使用 Serilog 和 .Net Core 5 捕获实例化错误
- google-apps-script - 使用 GmailApp 从 Google App 脚本创建 HTML 草稿
- javascript - How to filter multiple extension files using node js
- javascript - 基于条件开关案例的同一组件中的多个不同嵌套路由 - vue
- java - 无法让 String.valueOf(int) 方法工作
- c++ - 哪种数据结构可以轻松添加和删除项目并易于完全销毁?
- azure - Azure 监控日志 VS Azure 数据资源管理器
- javascript - 在 Reactjs 中实现 Animejs 脚本