function getExample6() { $books = \Foobooks\Book::orderBy('id', 'DESC')->get(); //$first = \Foobooks\Book::orderBy('id', 'DESC')->first(); //$last = \Foobooks\Book::orderBy('id','ASC')->first(); $first = $books->first(); $last = $books->last(); dump($books); dump($first); dump($last); //return view('books.index')->with('books', $books); // echo $books; /* foreach($books as $book){ echo $book->title; } */ }
public function getIndex(Request $request) { $books = \Foobooks\Book::orderBy('id', 'DESC')->get(); dump($books->toArray()); return view('books.index')->with('books', $books); }