您可以使用简单的路线:
Route::get('/displayPerPage/{perPage}', '[email protected]');
然后在控制器中:
public function index($perPgae)
{
$pages = Data::paginate($perPage);
作为替代方案,您可以只添加到URL像 '/书籍?perpage = 10 &排序依据=东西&为了=递减'。然后在控制器使用这个数据:
$perPage = Input::get('perpage');
$orderBy = Input::get('orderby');
$order = Input::get('order');
$pages = Data::orderBy($orderBy, $order)->paginate($perPage);
另一种方式来做到这一点是利用Laravel集体或简单的形式具有单按钮:
{!! Form::open(array('method' => 'Get', 'route' => array('myroute.edit', 10))) !!}
<button class="btn-xs btn-info">Edit</button>
{!! Form::close() !!}
,然后在控制器:
public function edit($perPage)
{
HTTPS ://laracasts.com/discuss/channels/general-discussion/generating-a-route-with-a-query-string-parameter – MECU
https://laravelcollective.com/docs/5.0/html有一个很棒的帮手功能' link_to_route',允许这是︰'link_to_route('route.name',$ title = null,$ parameters = array(),$ attributes = array());' – MECU
这就是我正在寻找,但是,我只是重新安排我的代码使用link_to_route方法,它擦除我的其他参数,'orderBy = total_payment&sortBy = DESC',并替换'displayPerPage = 10',我需要一些将追加url的东西。 – max234435