public function edit($id)
 {
     $book = Books::find($id);
     $categories = Category::get_form_list();
     $authors = Authors::get_form_list();
     return view('admin.books.edit', compact('book', 'categories', 'authors'));
 }
 public function destroy($id)
 {
     $author = Authors::find($id);
     ClydeUpload::exists($author->photo) == true ? ClydeUpload::delete($author->photo) : false;
     $author->delete();
     return back();
 }
Exemple #3
0
 public static function get_form_list()
 {
     $author = Authors::all(['id', 'name']);
     foreach ($author as $k) {
         $authors[$k->id] = $k->name;
     }
     return $authors;
 }
 public function run()
 {
     // CLEAR TABLE BOOKS
     Books::truncate();
     // SEEDS EXECUTE
     $Authors = Authors::all()->each(function ($author) {
         foreach (range(1, 10) as $v) {
             $category = Category::all(['id'])->random(1);
             $author->books()->save(factory('App\\Books')->make(['category_id' => $category->id]));
         }
     });
 }
 public function profile($slug)
 {
     $authors = Authors::findBySlug($slug);
     return view('authors.profile', compact('authors'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Authors::truncate();
     $posts = factory('App\\Authors', 30)->create();
 }