laravel - Laravel 5.7 简单分页
问题描述
在我们的应用程序中,我们有称为报告的模块,在此报告中将向您显示模块的摘要。
例子
General Journal Report - in this report will show you the summarize of the general journal module.
现在在我们的报告中需要实现分页,在查询生成器中应用分页时遇到问题。
控制器
$general_journals = GeneralJournalReportModel::getGeneralJournals();
$data['defined_gj'] = GeneralJournalReportItemsController::getDefinedGJById($general_journals);
我获取所有常规日志记录并将其存储在变量 general_journals 中,然后我将其传递给另一个控制器以执行其他操作(例如在列为空时进行一些错误处理)。
模型
public static function getGeneralJournals()
{
return DB::table('general_journals as gj')
->select('gj.id as id',
'gj.number as number',
'gj.posting_date as posting_date',
'gj.remarks as remarks',
'gj.document_reference as document_reference',
'gji.debit_amount as debit_amount',
'gji.credit_amount as credit_amount')
->leftJoin('general_journal_items as gji', 'gj.id', '=', 'gji.general_journal_id')
->where('gj.company_id', Auth::user()->company_id)
->where('gj.approval_status', 3)
->orderBy('gj.id', 'desc')
->simplePaginate(5);
}
看法
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 col-lg-12">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover general-journal-report-table" id="gj-report">
<thead class="thead-global">
<tr>
<th id="pj_sequence">Sequence No.</th>
<th id="pj_date">Posting Date</th>
<th id="pj_op">Transaction No.</th>
<th id="4">Document Reference</th>
<th id="5">Remarks</th>
<th id="6">Amount Due</th>
</tr>
</thead>
<tbody class="general-journal-report-details">
@if($defined_gj)
<?php $counter = 0; ;?>
<?php $total_debit = 0; ?>
@foreach($defined_gj as $key => $value)
<?php $counter++;?>
<?php $total_debit += $value->debit ;?>
<tr>
<td class="pj_sequence">{{$counter}}</td>
<td class="pj_date">{{$value->posting_date}}</td>
<td class="pj_op">{!! $value->number !!}</td>
<td>{{$value->doc_ref}}</td>
<td>{{$value->remarks}}</td>
@if($value->debit == '0')
<td></td>
@else
<td align="right"> {{number_format($value->debit,2)}}</td>
@endif
</tr>
@endforeach
<tr>
<td><b>Total</b></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td align="right"> {{number_format($total_debit)}}</td>
</tr>
@endif
</tbody>
</table>
</div>
{{ $general_journals->links() }}
</div>
当我使用 links() 我的按钮没有任何类。
问题:如何在链接按钮上放置一些类?
注意:我试过这个 {{ $general_journals->links() }} 但它只适用于上一个按钮(我还想在下一个按钮中应用该类)
解决方案
如果您想自定义分页视图,可以点击此链接https://laravel.com/docs/5.7/pagination#customizing-the-pagination-view
推荐阅读
- python - Python 类可下标但不可迭代
- git - emacs 不备份 git repo 中的文件
- recursion - Preorder traversal without recursion
- ansible - 可变模块字段
- json - How to create multiple instance of backendAddressPools, frontendports in Application Gateways through ARM template
- javascript - 制作响应式可折叠导航栏。我很难让 Javascript 在点击时工作
- google-sheets - Is there a way to filter a pivot query to remove the blank column
- react-native - 将 react-native 升级到 0.60、将组件复制到新项目或更改 package.json 版本的最佳方法?
- javascript - 二维数组在 JavaScript 中的意外结果
- python - 如何在 Cython 中有一个内存视图列表?