本文整理匯總了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());
});
}