diff --git a/Changelog b/Changelog index 998c6219b..3ae46bc5e 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-09 DariusIII + * Chg: Update comments handling in user profile page * Chg: Remove pager from profile * Chg: Use laravel pagination in forum * Chg: Add ForumController and routes diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index f520f8c40..a3e62548f 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -88,7 +88,7 @@ class ProfileController extends BasePageController // Pager must be fetched after the variables are assigned to smarty. $this->smarty->assign( [ - 'commentslist' => ReleaseComment::getCommentsForUserRange($userID, $offset, config('nntmux.items_per_page')), + 'commentslist' => ReleaseComment::getCommentsForUserRange($userID), 'exccats' => implode(',', UserExcludedCategory::getCategoryExclusionNames($userID)), 'saburl' => $sab->url, 'sabapikey' => $sab->apikey, diff --git a/app/Models/ReleaseComment.php b/app/Models/ReleaseComment.php index e73c9c98e..6d9e5bfd6 100644 --- a/app/Models/ReleaseComment.php +++ b/app/Models/ReleaseComment.php @@ -161,27 +161,17 @@ class ReleaseComment extends Model } /** - * Get comments for a user by limit. - * - * * @param $uid - * @param $start - * @param $num - * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[] + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ - public static function getCommentsForUserRange($uid, $start, $num) + public static function getCommentsForUserRange($uid) { - $comments = self::query() + return self::query() ->select(['release_comments.*', 'r.guid', 'r.searchname', 'u.username']) ->join('releases as r', 'r.id', '=', 'release_comments.releases_id') ->leftJoin('users as u', 'u.id', '=', 'release_comments.users_id') ->where('users_id', $uid) - ->orderBy('created_at', 'desc'); - - if ($start !== false) { - $comments->limit($num)->offset($start); - } - - return $comments->get(); + ->orderBy('created_at', 'desc') + ->paginate(config('nntmux.items_per_page')); } }