本文整理汇总了PHP中Paginator::page方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::page方法的具体用法?PHP Paginator::page怎么用?PHP Paginator::page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginator
的用法示例。
在下文中一共展示了Paginator::page方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHomePageList
public static function getHomePageList($category_id)
{
$total = static::where('forumtopics.forumcategory_id', '=', $category_id)->count();
$per_page = Config::get('forums::forums.topics_per_page');
$page = Paginator::page($total, $per_page);
$topics = DB::query('SELECT
forumtopics.id as id,
forumtopics.title as title,
forumtopics.slug as slug,
forumtopics.nb_messages as nb_messages,
forumtopics.nb_views as nb_views,
forumtopics.sticky as sticky,
forumtopics.created_at as created_at,
topicusers.username as topic_username,
fm.id as last_message_id,
fm.created_at as last_message_date,
users.username as last_message_username
FROM forumtopics
JOIN (SELECT forummessages.id, forummessages.user_id, forummessages.forumtopic_id, forummessages.created_at FROM forummessages ORDER BY forummessages.created_at DESC) as fm
ON fm.forumtopic_id = forumtopics.id
JOIN users ON fm.user_id = users.id
JOIN users as topicusers ON forumtopics.user_id = topicusers.id
WHERE forumtopics.forumcategory_id = ?
GROUP BY fm.forumtopic_id
ORDER BY forumtopics.sticky DESC, fm.created_at DESC
LIMIT ' . ($page - 1) * $per_page . ', ' . $per_page, array($category_id));
return Paginator::make($topics, $total, $per_page);
}
示例2: testHTMLOutput
public function testHTMLOutput()
{
$paginatorClass = new Paginator();
$records = array();
for ($i = 1; $i <= 100; $i++) {
$records['Key ' . $i] = 'Value ' . $i;
}
$paginator = $paginatorClass->page(4)->perPage(10)->make($records, 'Array');
// Cover foreach, iterator
foreach ($paginator as $item) {
}
$expected = '<ul class="pagination"><li class="prev"><a href="?page=3">«</a></li><li class=""><a href="?page=2">2</a></li><li class=""><a href="?page=3">3</a></li><li class="active current"><a href="?page=4">4</a></li><li class=""><a href="?page=5">5</a></li><li class=""><a href="?page=6">6</a></li><li class="next"><a href="?page=5">»</a></li></ul>';
$this->assertEquals($expected, (string) $paginator);
}