app/Http/Controllers/PostsController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $posts = Post::orderBy('created_at','desc')->paginate(4);
        return view('posts.index')->with('posts', $posts);
    }
public function index ( ) { $ posts = Post :: orderBy ( 'created_at' , 'desc' ) -> paginate ( 4 ) ; return view ( 'posts.index' ) -> with ( 'posts' , $ posts ) ; }
Display a listing of the resource.
Display a listing of the resource .
// $posts = Post::all(); // return Post::where('title','Post Two')->get(); if we want to get indivudual post's vb where categorie is... // $posts = DB::select('SELECT * FROM posts'); gegeven uit database halen met sql inplaats van eloquent // $posts = Post::orderBy('title','desc')->take(1)->get(); // $posts = Post::orderBy('title','desc')->get(); // creats the pagination of the page (4) = 4 posts per page