Skip to content
Snippets Groups Projects
Commit 50e38780 authored by Bitha17's avatar Bitha17
Browse files

add event pagination

parent df3218b5
Branches
Tags
No related merge requests found
......@@ -32,5 +32,16 @@ class EventController {
public function getAllEvents() {
return $this->eventModel->getAllEvents();
}
public function paginateEvents($page=1,$pagesize=10,$events) {
$maxpage = ceil(count($events)/$pagesize);
if ($page > $maxpage) {
$page = $maxpage;
}
$offset = $pagesize * ($page-1);
$selectedEvents = array_slice($events, $offset, $pagesize);
return $selectedEvents;
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment