function getExample8() { $book = \App\Book::first(); $author = $book->author; echo $book->title . ' was written by ' . $book->author->first_name . ' ' . $book->author->last_name; dump($book->toArray()); }
public function home() { $settings = Setting::first(); $books = Book::get(); if (!count($books)) { return redirect('/dashboard'); } $currentbook = Book::first(); return view('front.book', ['books' => $books, 'settings' => $settings, 'currentbook' => $currentbook]); }
function getExample8() { $book = \App\Book::orderBy('id', 'DESC')->first(); dump($book->toArray()); echo 'The book title is' . $book->title . '<br/>'; $book = \App\Book::first(); $author = $book->author; echo $book->title . ' was written by ' . $author->first_name . ' ' . $author->last_name; dump($book->toArray()); return 'Example 8'; }