/** * @return \Illuminate\View\View */ public function index() { //Auth::user(); //$articles = Article::latest('published_at')->where('published_at', '<=', Carbon::now())->get(); $articles = Article::latest('published_at')->publish()->get(); // scope function //return $articles; // return json $latest = Article::latest()->first(); //return view('article.index', compact('articles')); return view('article.index', ['articles' => $articles, 'latest' => $latest]); }
public function compose(View $view) { $view->with('latest', Article::latest()->first()); }