本文整理汇总了PHP中app\Board::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::orderBy方法的具体用法?PHP Board::orderBy怎么用?PHP Board::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Board
的用法示例。
在下文中一共展示了Board::orderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boardStats
/**
* Returns the information specified by boardStats
*
* @return array (indexes and vales based on $boardStats)
*/
protected function boardStats()
{
$controller =& $this;
$stats = Cache::remember('index.boardstats', 60, function () use($controller) {
$stats = [];
foreach ($controller->boardStats as $boardStat) {
switch ($boardStat) {
case "boardIndexedCount":
$stats[$boardStat] = Board::whereIndexed()->count();
break;
case "startDate":
$stats[$boardStat] = Board::orderBy('created_at', 'desc')->take(1)->pluck('created_at')->format("M jS, Y");
break;
case "boardTotalCount":
$stats[$boardStat] = Board::count();
break;
case "postCount":
$stats[$boardStat] = Board::sum('posts_total');
break;
case "postRecentCount":
$stats[$boardStat] = Post::recent()->count();
break;
}
}
return $stats;
});
return $stats;
}
示例2: importInfinityBoardPosts
/**
* Imports posts.
*
* @return void
*/
public function importInfinityBoardPosts()
{
$this->info("\tImporting posts ...");
$query = Board::orderBy('board_uri', 'desc');
$query = $query->where('board_uri', 'jim');
$query->chunk(1, function ($boards) {
foreach ($boards as $board) {
try {
$tTable = $this->tcon->table("posts_{$board->board_uri}");
$tCount = $tTable->count();
} catch (\Illuminate\Database\QueryException $e) {
$this->warn("\t\tMissing board /{$board->board_uri}/");
continue;
}
if ($tCount >= $board->posts_total && $board->board_uri != "cow") {
$this->line("\t\tSkipping /{$board->board_uri}/");
continue;
}
$this->line("\t\tTruncating Infinity Next posts for /{$board->board_uri}/");
$post_ids = $board->posts()->withTrashed()->lists('post_id');
FileAttachment::whereIn('post_id', $post_ids)->forceDelete();
$board->posts()->withTrashed()->forceDelete();
$board->posts_total = 0;
$board->save();
$this->line("\t\tLocking Next posts for /{$board->board_uri}/");
$this->tcon->unprepared(DB::raw("LOCK TABLES posts_{$board->board_uri} WRITE"));
@file_get_contents("http://banners.8ch.net/status/{$board->board_uri}/migrating");
$this->line("\t\tImporting posts from /{$board->board_uri}/");
// Post Info
$postsMade = 0;
$validThreads = [];
// Attachment Info
$storageLinked = 0;
$attachmentsMade = 0;
// Threads first, replies by id.
$query = $tTable->orderByRaw('thread asc, id asc');
$bar = $this->output->createProgressBar($tCount);
$query->chunk(50, function ($posts) use(&$bar, &$validThreads, &$board, &$postsMade, &$attachmentsMade) {
$models = [];
// thread, subject, email, name, trip, capcode, body, body_nomarkup, time, bump, files, num_files, filehash, password, ip, sticky, locked, cycle, sage, embed, edited_at
// post_id | board_uri | board_id | reply_to | reply_to_board_id | reply_count | reply_last | bumped_last | created_at | updated_at | updated_by | deleted_at | stickied | stickied_at | bumplocked_at | locked_at | author_ip | author_id | author_country | author_ip_nulled_at | author | insecure_tripcode | capcode_id | adventure_id | subject | email | password | body | body_parsed | body_parsed_at | body_html | featured_at | body_too_long | body_parsed_preview | flag_id | reply_file_count
foreach ($posts as $post) {
$model = $this->importInfinityPost($post, $board, $validThreads);
if (!is_array($model)) {
continue;
}
$model = new Post($model);
$model->save();
++$postsMade;
// Have to save threads so we have a post_id.
if (!$post->thread) {
$validThreads[$post->id] = $model;
}
$attachmentsMade += $this->importInfinityPostAttachments($model, $board, $post);
}
$bar->advance(count($posts));
foreach ($validThreads as $validThread) {
$validThread->reply_count = $validThread->replies()->count();
$validThread->save();
}
});
$this->tcon->unprepared(DB::raw("UNLOCK TABLES"));
@file_get_contents("https://banners.8ch.net/status/{$board->board_uri}/horizon");
$this->line("\n\t\t\tMade {$postsMade} posts with {$attachmentsMade} attachments for /{$board->board_uri}/.");
}
});
}