1
我正在嘗試對我的觀點進行分頁。我用下面的語法來做到這一點: 路線:分頁時NotFoundHTTPException。 Laravel
Route::get('Bill/view/month/history','[email protected]');
控制器:
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的網址:
http://localhost:8000/Bill/view/month/custom/url?page=2
我該如何解決這個問題?誰能幫我?