【问题标题】:Laravel 5.7 simple paginationLaravel 5.7 简单分页
【发布时间】:2020-03-01 10:18:27
【问题描述】:

在我们的应用程序中,我们有称为报告的模块,在此报告中将向您显示模块的摘要。

示例

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() }} 但它只适用于上一个按钮(我还想在下一个按钮中应用该类)

【问题讨论】:

    标签: laravel pagination laravel-5.7


    【解决方案1】:

    试试这个

    {{ $general_journals->links('pagination::bootstrap-4') }}
    

    替换为您的 laravel 引导程序版本。

    【讨论】:

      【解决方案2】:

      如果你想自定义分页视图,可以关注这个链接https://laravel.com/docs/5.7/pagination#customizing-the-pagination-view

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-06-20
        • 1970-01-01
        • 2015-06-07
        • 1970-01-01
        • 1970-01-01
        • 2020-11-19
        • 2017-05-24
        相关资源
        最近更新 更多