Skip to content

Commit 12f43d0

Browse files
committed
Merge pull request #52 from yhbyun/hotfixes/patched
Fixed finxMostCommented pagination bug
2 parents aed545a + d15b825 commit 12f43d0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Tricks/Repositories/Eloquent/TrickRepository.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ public function findMostCommented($perPage = 9)
125125
return $trick->comment_count;
126126
})->reverse();
127127

128-
return \Paginator::make($tricks->all(), count($tricks), $perPage);
128+
$page = \Input::get('page', 1);
129+
$skip = ($page - 1) * $perPage;
130+
$items = $tricks->all();
131+
array_splice($items, 0, $skip);
132+
133+
return \Paginator::make($items, count($tricks), $perPage);
129134
}
130135

131136
/**

0 commit comments

Comments
 (0)