示例#1
0
 public function getIndex()
 {
     $updated = strtotime("0000-00-00 00:00:00");
     if (BlogPost::where('updated_at', $updated)->get()) {
         $blogsOrderby = BlogPost::orderBy('created_at', 'desc')->simplePaginate(2);
     } else {
         $blogsOrderby = BlogPost::orderBy('updated_at', 'desc')->simplePaginate(2);
     }
     return view('index')->with('blogsOrderby', $blogsOrderby);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $blogposts = BlogPost::where('status', '=', 3)->paginate(10);
     return view('blog.index', ['page_title' => 'Статьи', 'blogposts' => $blogposts]);
 }