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); }
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); }
public function compose($view) { $latest = Article::latest()->first(); $view->with(compact('latest')); }
public function index() { $articles = Article::latest('published_at')->get(); return view('articles.index', compact('articles')); }
public function index() { //return \Auth::user(); $articles = Article::latest('published_at')->published()->get(); return view('article.index', compact('articles')); }
/** * Compose the navigation bar. */ private function composeNavigation() { view()->composer('partials.nav', function ($view) { $view->with('latest', Article::latest()->first()); }); }