2 回答
TA贡献1813条经验 获得超2个赞
您可以计算每个请求的总飞行时间。这未经测试,但假设它应该有效。
$logBook = $this->log_book->orderBy('flight_date','asc');
$logBookPagination = $logBook->paginate(18);
// change the offset value to a value that makes sense for you
$logBookFlightTime = $logBook->offset(0)->limit($logBookPagination->perPage() * $logBookPagination->currentPage())->sum('id'); // replace with your column
return [
'logBook' => $logBookPagination,
'totalFlightTime' => $logBookFlightTime
];
为了解释我正在做什么,我从0中获取模型切片 - 当前页面,然后添加所有这些模型的飞行时间。
TA贡献1817条经验 获得超6个赞
我解决了这个问题。
$currentPage = $logs->currentPage();
if ($currentPage == 1) {
$totalPrevPages = $flight_total_time;
$flightInsTimePrevPages = $flight_ins_time;
$total_time=$totalPrevPages + $totalCurrentPage;
}
else {
$total_time = $this->log_book->log()->orderBy('leg_date','asc')->limit($count * $currentPage)->sum('total_time') + $flight_total_time;
$totalPrevPages = $total_time - $totalCurrentPage ;
}
- 2 回答
- 0 关注
- 66 浏览
添加回答
举报