本文整理汇总了PHP中app\models\Article::latest方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::latest方法的具体用法?PHP Article::latest怎么用?PHP Article::latest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Article
的用法示例。
在下文中一共展示了Article::latest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
//elloquent method
$articles = Article::latest('published_at')->published()->limit(5)->get();
//pass in articles variable
//return view goes directly to the views directory
return view('home')->with('articles', $articles);
}
示例2: index
public function index()
{
//elloquent method
if (Auth::check()) {
$articles = Article::latest('published_at')->published()->get();
} else {
$articles = Article::latest('published_at')->published()->limit(5)->get();
}
//pass in articles variable
//return view goes directly to the views directory
return view('articles.index')->with('articles', $articles);
}
示例3: compose
public function compose($view)
{
$latest = Article::latest()->first();
$view->with(compact('latest'));
}
示例4: index
public function index()
{
$articles = Article::latest('published_at')->get();
return view('articles.index', compact('articles'));
}
示例5: index
public function index()
{
//return \Auth::user();
$articles = Article::latest('published_at')->published()->get();
return view('article.index', compact('articles'));
}
示例6: composeNavigation
/**
* Compose the navigation bar.
*/
private function composeNavigation()
{
view()->composer('partials.nav', function ($view) {
$view->with('latest', Article::latest()->first());
});
}