public function index() { $articles = Articles::latest('published_at')->published()->get(); $latest = Articles::latest()->first(); if (is_null($articles)) { abort(404); } return view('articles.index', compact('articles', 'latest')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (\Auth::guest()) { $articles = Articles::latest()->published()->simplePaginate(Articles::itemsPerPage); } else { $articles = Articles::latest()->simplePaginate(Articles::itemsPerPage); } $pageDescription = 'Some description'; return view('articles.index', compact('articles', 'pageDescription')); }
/** * Compose the navigation bar */ private function composeNavigation() { view()->composer('partials.nav', function ($view) { $view->with('latest', Articles::latest()->first()); }); }
public function index() { $articles = Articles::latest('published_at')->published()->get(); // $articles = Articles::orderBy('published_at')->get(); return view('articles.index', compact('articles')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $articles = Articles::latest()->simplePaginate(5); return view('articles.index', compact('articles')); }
public function index() { //code mới, chỉ lấy các bài viết từ thời điểm hiện tại trở về trước $articles = Articles::latest('created_at')->where('created_at', '<=', Carbon::now())->get(); return view("articles")->with("articles", $articles); }
public function articles() { $articles = Articles::latest()->get(); return view('pages.main', compact('articles')); }
public function index() { $articles = Articles::latest()->get(); return view('articles.index', compact('articles')); }
/** * Bootstrap the application services. * * @return void */ public function boot() { view()->composer('partials.last_art', function ($view) { $view->with('latest', \App\Articles::latest()->first()); }); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show(Articles $article) { $latest = $article->latest()->first(); return view('articles.show', compact('article')); }