Skip to content

Commit 6dea11f

Browse files
qschmickroshangautam
authored andcommitted
[fix] task list pagination
- adds support to pass query params to pagination view resolves #185
1 parent 820c7a3 commit 6dea11f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

resources/views/partials/pagination.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
@if ($page == $paginator->currentPage())
2121
<li class="uk-active"><span>{{ $page }}</span></li>
2222
@else
23-
<li><a href="{{ $url }}">{{ $page }}</a></li>
23+
<li><a href="{{ $url . ($params ?? '') }}">{{ $page }}</a></li>
2424
@endif
2525
@endforeach
2626
@endif
2727
@endforeach
2828

2929
{{-- Next Page Link --}}
3030
@if ($paginator->hasMorePages())
31-
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>
31+
<li><a href="{{ $paginator->nextPageUrl() . ($params ?? '') }}" rel="next">&raquo;</a></li>
3232
@else
3333
<li class="uk-disabled"><span>&raquo;</span></li>
3434
@endif

resources/views/tasks/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@
5959
<a class="uk-button uk-button-primary uk-button-small uk-visible@m" href="{{route('totem.tasks.export')}}">Export</a>
6060
</span>
6161
</div>
62-
{{$tasks->links('totem::partials.pagination')}}
62+
{{$tasks->links('totem::partials.pagination', ['params' => '&' . http_build_query(array_filter(request()->except('page')))])}}
6363
@stop

src/Http/Controllers/TasksController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Studio\Totem\Task;
66
use Studio\Totem\Totem;
7+
use Illuminate\Database\Eloquent\Builder;
78
use Studio\Totem\Contracts\TaskInterface;
89
use Studio\Totem\Http\Requests\TaskRequest;
910

@@ -41,7 +42,7 @@ public function index()
4142
'last_ran_at',
4243
'average_runtime',
4344
], ['description'=>'asc'])
44-
->when(request('q'), function ($query) {
45+
->when(request('q'), function (Builder $query) {
4546
$query->where('description', 'LIKE', '%'.request('q').'%');
4647
})
4748
->paginate(20),

0 commit comments

Comments
 (0)