【发布时间】:2016-10-31 17:16:39
【问题描述】:
我正在尝试对我的观点进行分页。我使用以下语法来做到这一点: 路线:
Route::get('Bill/view/month/history','BillController@monthHistory');
控制器:
public function monthHistory(Request $request)
{
$month= $request->month;
$bills=Bill::orderBy('created_at', 'desc')->where('month',$month)->paginate(7);
$bills->setPath('custom/url');
return view('Bill.monthResult',compact('bills'));
}
查看:
<div class="row">
<div class="col-sm-12">
@section ('cotable_panel_title','Bills')
@section ('cotable_panel_body')
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Student</th>
<th>Grade</th>
<th>Month</th>
<th>Date Published</th>
<th>Amount</th>
<th>Paid</th>
<th>Balance</th>
<th>User</th>
</tr>
</thead>
<tbody>
@foreach($bills as $bill)
<tr class="info">
<td>{{$bill->id}}</td>
<td>{{$bill->student->first_name}}</td>
<td>{{$bill->grade->grade_name}}</td>
<td>{{$bill->month}}</td>
<td>{{$bill->date_published}}</td>
<td>{{$bill->amount}}</td>
<td>{{$bill->paid}}</td>
<td>{{$bill->fee_status}}</td>
<td>{{$bill->user}}</td>
</tr>
@endforeach
</tbody>
</table>
@endsection
@include('widgets.panel', array('header'=>true, 'as'=>'cotable'))
</div>
</div>
</div>
{!! $bills->render() !!}
虽然第一页的分页工作正常,但当我点击下一页时,它会抛出带有 URL 的 not foundhttpexception:
http://localhost:8000/Bill/view/month/custom/url?page=2
我该如何解决这个问题?谁能帮帮我?
【问题讨论】:
标签: pagination routes laravel-5.2