本文整理汇总了PHP中app\Board::getThreadsForIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::getThreadsForIndex方法的具体用法?PHP Board::getThreadsForIndex怎么用?PHP Board::getThreadsForIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::getThreadsForIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThreads
/**
* Returns a thread and its replies.
*
* @param \App\Board $board
* @return Response
*/
public function getThreads(Board $board)
{
// Determine what page we are on.
$pages = $board->getPageCount();
$response = [];
for ($i = 0; $i < $pages; ++$i) {
$pageArray = ['page' => $i, 'threads' => []];
$threads = $board->getThreadsForIndex($i);
foreach ($threads as $thread) {
$pageArray['threads'][] = ['no' => (int) $thread->board_id, 'last_modified' => (int) $thread->bumped_last->timestamp];
}
$response[] = $pageArray;
}
return response()->json($response);
}
示例2: getIndex
/**
* Show the board index for the user.
* This is usually the last few threads, depending on the optional page
* parameter, which determines the thread offset.
*
* @var Board $board
* @var integer $page
* @return Response
*/
public function getIndex(Board $board, $page = 1)
{
// Determine what page we are on.
$pages = $board->getPageCount();
// Clamp the page to real values.
if ($page <= 0) {
$page = 1;
} elseif ($page > $pages) {
$page = $pages;
}
// Determine if we have a next/prev button.
$pagePrev = $page > 1 ? $page - 1 : false;
$pageNext = $page < $pages ? $page + 1 : false;
// Load our list of threads and their latest replies.
$posts = $board->getThreadsForIndex($page);
return $this->apiResponse($posts);
}
示例3: getIndex
/**
* Show the board index for the user.
* This is usually the last few threads, depending on the optional page
* parameter, which determines the thread offset.
*
* @param Board $board
* @param integer $page
* @return Response
*/
public function getIndex(Board $board, $page = 1)
{
// Determine what page we are on.
$pages = $board->getPageCount();
// Clamp the page to real values.
if ($page <= 0) {
$page = 1;
} elseif ($page > $pages) {
$page = $pages;
}
// Determine if we have a next/prev button.
$pagePrev = $page > 1 ? $page - 1 : false;
$pageNext = $page < $pages ? $page + 1 : false;
// Load our list of threads and their latest replies.
$posts = $board->getThreadsForIndex($page);
return $this->view(static::VIEW_BOARD, ['board' => &$board, 'posts' => $posts, 'reply_to' => false, 'pages' => $pages, 'page' => $page, 'pagePrev' => $pagePrev, 'pageNext' => $pageNext]);
}