Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $author_id = \Foobooks\Author::where('last_name', '=', 'Fitzgerald')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'The Great Gatsby', 'author_id' => $author_id, 'published' => 1925, 'cover' => 'http://img2.imagesbn.com/p/9780743273565_p0_v4_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/the-great-gatsby-francis-scott-fitzgerald/1116668135?ean=9780743273565']);
     $author_id = \Foobooks\Author::where('last_name', '=', 'Plath')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'The Bell Jar', 'author_id' => $author_id, 'published' => 1963, 'cover' => 'http://img1.imagesbn.com/p/9780061148514_p0_v2_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/bell-jar-sylvia-plath/1100550703?ean=9780061148514']);
     $author_id = \Foobooks\Author::where('last_name', '=', 'Angelou')->pluck('id');
     DB::table('books')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'title' => 'I Know Why the Caged Bird Sings', 'author_id' => $author_id, 'published' => 1969, 'cover' => 'http://img1.imagesbn.com/p/9780345514400_p0_v1_s114x166.JPG', 'purchase_link' => 'http://www.barnesandnoble.com/w/i-know-why-the-caged-bird-sings-maya-angelou/1100392955?ean=9780345514400']);
 }
Exemplo n.º 2
0
 public function getEdit($id = null)
 {
     $book = \Foobooks\Book::find($id);
     $authors = \Foobooks\Author::orderby('last_name', 'ASC')->get();
     dump($authors);
     $authors_for_dropdown = [];
     foreach ($authors as $author) {
         $authors_for_dropdown[$author->id] = $author->last_name . ', ' . $author->first_name;
     }
     dump($authors_for_dropdown);
     //if we don't find the book
     if (is_null($book)) {
         \Session::flash('flash_message', 'Book not found.');
         return redirect('\\books');
     }
     //return view('books.edit')->with(['book'=>$book, 'authors_for_dropdown'=>$authors_for_dropdown]);
     return view('books.edit')->with(['book' => $book, 'authors_for_dropdown' => $authors_for_dropdown]);
 }