简体   繁体   English

在Laravel 5.1中对联合查询进行手动分页?

[英]Manual pagination for union query in laravel 5.1?

I have union query , 我有联合查询,

 $invoices = DB::table('invoices')
            ->select('id', 'client_id', 'created_at')
            ->where('client_id', '=', $id)
            ->whereNull('deleted_at');
    $payments = DB::table('payments')
            ->select('id', 'client_id', 'created_at')
            ->where('client_id', '=', $id)
            ->whereNull('deleted_at');
    return $invoices->union($payments)
                    ->orderBy('created_at', 'asc')
                    ->get();

Here I want to apply pagination and laravel buil in pagination will not be supported. 在这里我要应用分页,并且不支持分页中的laravel buil。 But I don't know about manual pagination and found one answer here manual pagination - stack question but I couldn't solve my issue. 但是我不了解手动分页,在这里找到了一个手动分页的答案-堆栈问题,但我无法解决我的问题。

Is there any other good tutorial which help me to learn manual pagination in laravel 5.1. 是否有其他好的教程可以帮助我学习laravel 5.1中的手动分页。

Please help me to implement pagination for above query? 请帮我实现上述查询的分页吗?

进行一些计算并将参数传递给方法->skip(100)->take(10)->get() ,其中跳过和获取的工作方式类似于LIMIT 100, 10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM