/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['novel', 'fiction', 'classic', 'wealth'], 'The Bell Jar' => ['novel', 'fiction', 'classic', 'women'], 'I know Why the Caged Bird Sings' => ['autobiography', 'nonfiction', 'classic', 'women']];
     foreach ($books as $title => $tags) {
         $book = \Foobooks\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \Foobooks\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
 public function postEdit(Request $request)
 {
     $book = \Foobooks\Book::find($request->id);
     $book->title = $request->title;
     $book->author_id = $request->author;
     $book->cover = $request->cover;
     $book->published = $request->published;
     $book->purchase_link = $request->purchase_link;
     $book->save();
     \Session::flash('flash_message', 'Your book was updated');
     return redirect('/books/edit/' . $request->id);
 }
 function getExample100()
 {
     $books = \Foobooks\Book::with('author')->get();
     foreach ($books as $book) {
         echo '<br>' . $book->title . ' is written by: ' . $book->author->first_name;
     }
 }