本文整理匯總了PHP中app\Board::getThread方法的典型用法代碼示例。如果您正苦於以下問題:PHP Board::getThread方法的具體用法?PHP Board::getThread怎麽用?PHP Board::getThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Board
的用法示例。
在下文中一共展示了Board::getThread方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getThread
/**
* Renders a thread.
*
* @var \App\Http\Requests\Request $request
* @var Board $board
* @var integer|null $thread
* @return Response
*/
public function getThread(Request $request, Board $board, $thread = null)
{
if (is_null($thread)) {
return redirect($board->board_uri);
}
// Pull the thread.
$thread = $board->getThread($thread);
if (!$thread) {
return abort(404);
}
if ($thread->reply_to) {
return redirect("{$board->board_uri}/thread/{$thread->op->board_id}");
}
return $this->view(static::VIEW_THREAD, ['board' => $board, 'posts' => [$thread], 'reply_to' => $thread->board_id]);
}
示例2: getThread
/**
* Returns a thread and its replies to the client.
*
* @var Board $board
* @var integer|null $thread
* @return Response
*/
public function getThread(Request $request, Board $board, $thread)
{
if (is_null($thread)) {
return abort(404);
}
$input = $request->only('updatesOnly', 'updatedSince');
if (isset($input['updatesOnly'])) {
$updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', 0));
return Post::where('posts.board_uri', $board->board_uri)->withEverything()->where(function ($query) use($thread) {
$query->where('posts.reply_to_board_id', $thread);
$query->orWhere('posts.board_id', $thread);
})->where(function ($query) use($updatedSince) {
$query->where('posts.updated_at', '>=', $updatedSince);
$query->orWhere('posts.deleted_at', '>=', $updatedSince);
})->withTrashed()->orderBy('posts.created_at', 'asc')->get();
} else {
// Pull the thread.
$thread = $board->getThread($thread);
if (!$thread) {
return abort(404);
}
}
return $thread;
}