本文整理汇总了PHP中app\Post::recent方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::recent方法的具体用法?PHP Post::recent怎么用?PHP Post::recent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::recent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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 "boardCount":
$stats[$boardStat] = Board::whereIndexed()->count();
break;
case "boardIndexedCount":
$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;
}
示例3: getIndex
/**
* GET /
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getIndex()
{
$posts = Post::recent(3)->get();
return view('home.index', compact('posts'));
}