Laravel 4 具有雄辩查询的Laravel分页

Laravel 4 具有雄辩查询的Laravel分页,laravel-4,eloquent,blade,laravel-paginate,Laravel 4,Eloquent,Blade,Laravel Paginate,我试图分页我的模板上有一个表 这是我在控制器中的函数,它具有雄辩的查询 public function orderbydate() { $order =DB::table('sales_flat_order_items as s') ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id') ->select(arra

我试图分页我的模板上有一个表

这是我在控制器中的函数,它具有雄辩的查询

public function orderbydate()
    {

        $order =DB::table('sales_flat_order_items as s')
                ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
                ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                    DB::Raw('sum(s.row_total) as row_total'),
                    DB::Raw('sum(s.discount_amount) as discount_amount'),
                    DB::Raw('sum(s.tax_amount) as tax_amount'),
                    DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                    DB::Raw('sum(w.subtotal) as subtotal'), 
                    DB::Raw('sum(w.total_invoiced) as total_invoiced'), 
                    DB::Raw('sum(w.shipping_amount) as shipping_amount')))
                ->where('qty_canceled','=','0')
                ->where('status','!=','canceled')
                ->get();

        $orderbydate = DB::table('sales_flat_order_items as s')
                ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
                ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                    DB::Raw('sum(s.row_total) as row_total'),
                    DB::Raw('sum(s.discount_amount) as discount_amount'),
                    DB::Raw('sum(s.tax_amount) as tax_amount'),  
                    DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                    DB::Raw('sum(w.subtotal) as subtotal'),
                    DB::Raw('DATE(w.created_at) days'), 
                    DB::Raw('sum(w.total_invoiced) as total_invoiced'),
                    DB::Raw('sum(w.shipping_amount) as shipping_amount')))
                ->where('qty_canceled','=','0')
                ->where('status','!=','canceled')
                ->groupBy('days')
                ->orderBy('s.created_at')
                ->get();

            return View::make('sales_flat_orders.orderbydate', compact('order','orderbydate'), ['orderbydate'=>Paginate(3)]);
    }
我想在模板中使用分页。所以我喜欢这样做

    @foreach(array_chunk($orderbydate->getCollection()->all(), 3) as $row)
      <div class = "row">
          @foreach($row as $s)
          <article class = "col-md-4">
     <tbody>
      <tr class="odd gradeX">
         <td>{{date("d F, Y",strtotime($s->days))}}</td>
         <td>{{ round($s->qty_ordered, 2) }}</td>
         <td>{{round($s->subtotal,2)}}</td>
         <td>{{round($s->tax_amount,2)}}</td>
         <td>{{round($s->discount_amount,2)}}</td>
         <td>{{round($s->row_total,2)}}</td>
         <td>{{round($s->amount_refunded,2)}}</td>
         <td>{{round($s->total_invoiced,2)}}</td>
         <td>{{round($s->shipping_amount,2)}}</td>
      </tr>
    </article>
     @endforeach
    @endforeach
@foreach(数组块($orderbydate->getCollection()->all(),3)作为$row)
@foreach($s行)
{{date(“df,Y”,strottime($s->days))}
{{round($s->订购数量,2)}
{{四舍五入($s->小计,2)}
{{round($s->税额,2)}
{{round($s->折扣金额,2)}
{{round($s->row_total,2)}
{{round($s->退款金额,2)}
{{round($s->发票总额,2)}
{{round($s->运费金额,2)}
@endforeach
@endforeach
但这种方法不起作用。我哪里做错了


提前感谢

如果要使用分页而不是
get
方法,则需要使用
paginate
方法

例如,工作分页应如下所示:

Paginator::setCurrentPage($page);
Paginator::setBaseUrl($baseUrl);
Paginator::setPageName('page');
$users = User::paginate(15);
现在,在刀片模板中,您可以在
foreach
循环中显示用户,并添加分页链接:

@foreach ($users as $user)
  {{{ $user->name }}}
@endforeach

{{ $users->links() }}

你当然也应该看看

你能为我的雄辩提问展示一下我们需要怎么做吗?@CoolD看看这个:嘿@Marcin。我在上面贴了另一个问题。你能看一下吗?嘿@marcin,我已经在上面的链接上发布了这个问题