Laravel 4 : Pagination and Sort Header

爱⌒轻易说出口 提交于 2019-12-06 06:33:57

Maybe you already get the solution by the time, but I made this:

In Your Controller:

$sort = Input::get('sort')=== '' ? 'id': Input::get('sort');
$sort_dir = Input::get('sort_dir') === 'asc' ? 'asc' : 'desc';

In your view/admin/admins.blade.php you can manually create the link like this:

First, define $page

@if($page = $admins->getCurrentPage() )@endif

Then

<th>
       @if ($sort == 'first_name' && $sort_dir == 'asc')
          <a href="{{ Request::url() }}?page={{$page}}&sort_dir=desc&sort={{$sort}}">First Name</a>
       @else
          <a href="{{ Request::url() }}?page={{$page}}&sort_dir=asc&sort={{$sort}}">First Name</a>
       @endif
</th>

Must to be another way, but this worked for me!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!