在我们的应用程序中,我们有一个称为“报告”的模块,该报告中将向您显示该模块的摘要。
示例
General Journal Report - in this report will show you the summarize of the general journal module.
现在我们的报告中需要实现分页,在查询生成器中应用分页时遇到问题。
Controller
$general_journals = GeneralJournalReportModel::getGeneralJournals();
$data['defined_gj'] = GeneralJournalReportItemsController::getDefinedGJById($general_journals);
[我获取所有常规日志记录并将其存储在变量general_journals中,然后将其传递到另一个控制器中以执行其他操作(例如,当列为null时进行一些错误处理)。
模型
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()}},但它仅在上一个按钮上起作用(我也想在下一个按钮上应用该类)
尝试一下
{{ $general_journals->links('pagination::bootstrap-4') }}
替换为您的laravel bootstrap版本。
如果要自定义分页视图,则可以单击此链接https://laravel.com/docs/5.7/pagination#customizing-the-pagination-view