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'));
 }
Ejemplo n.º 2
0
 /**
  * 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'));
 }
Ejemplo n.º 3
0
 /**
  * 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'));
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 public function articles()
 {
     $articles = Articles::latest()->get();
     return view('pages.main', compact('articles'));
 }
Ejemplo n.º 8
0
 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());
     });
 }
Ejemplo n.º 10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Articles $article)
 {
     $latest = $article->latest()->first();
     return view('articles.show', compact('article'));
 }