From 7bbaa630a8f5df0e8cd4506ddeb8e6ae9bb684a6 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 19 Apr 2018 22:52:28 +0200 Subject: [PATCH] Fix group list pagination --- Changelog | 1 + app/Http/Controllers/Admin/GroupController.php | 2 +- app/Models/Group.php | 15 +++++---------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Changelog b/Changelog index c073abb3c..3a8e29bee 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-19 DariusIII + * Fix: Fix group list pagination * Fix: Add missing group routes * Fix: Fix bugs in redirects * Fix: Fix link on content addition diff --git a/app/Http/Controllers/Admin/GroupController.php b/app/Http/Controllers/Admin/GroupController.php index 9e7e04890..ccc773387 100644 --- a/app/Http/Controllers/Admin/GroupController.php +++ b/app/Http/Controllers/Admin/GroupController.php @@ -22,7 +22,7 @@ class GroupController extends BasePageController $this->smarty->assign( [ 'groupname' => $groupName, - 'grouplist' => Group::getGroupsRange(config('nntmux.items_per_page'), $groupName), + 'grouplist' => Group::getGroupsRange($groupName), ] ); diff --git a/app/Models/Group.php b/app/Models/Group.php index c3533d1a6..2de52f2fc 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -199,16 +199,14 @@ class Group extends Model } /** - * Gets all groups and associated release counts. + * Gets all groups. * * - * @param bool $offset - * @param bool $limit * @param string $groupname - * @param null|bool $active - * @return \Illuminate\Database\Eloquent\Collection|static[] + * @param null $active + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ - public static function getGroupsRange($offset = false, $limit = false, $groupname = '', $active = null) + public static function getGroupsRange($groupname = '', $active = null) { $groups = self::query()->groupBy('id')->orderBy('name'); @@ -222,11 +220,8 @@ class Group extends Model $groups->where('active', '=', 0); } - if ($offset !== false) { - $groups->limit($limit)->offset($offset); - } - return $groups->get(); + return $groups->paginate(config('nntmux.items_per_page')); } /**