当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::page方法代码示例

本文整理汇总了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);
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:28,代码来源:forumtopic.php

示例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">&laquo;</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">&raquo;</a></li></ul>';
     $this->assertEquals($expected, (string) $paginator);
 }
开发者ID:atiarda,项目名称:strana,代码行数:14,代码来源:PaginatorTest.php


注:本文中的Paginator::page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。