public function author() { if (Request::ajax()) { $data = Request::get('data'); $sort = Request::get('sort'); $list = Request::get('list'); switch ($data) { case 'pp': $author = Author::find($list); $author_book = Book::where('author_id', $list)->get(); return view('front.partials.list_item_pp_author', ['data' => $author, 'author_book' => $author_book]); case 'word': $author = Author::where('name', 'LIKE', $list . '%'); return view('front.partials.list_item_word', ['data' => $author->paginate(9), 'word' => $list]); default: $authors = DB::table('Authors'); $author = HomeController::sort($authors, $sort); return view('front.partials.list_item_all', ['data' => $author->paginate(9)]); } } $author_list = Author::orderBy('name', 'ASC')->paginate(9); $author_word = Author::select(DB::raw('substr(name,1,1) as alpha'))->groupBy(DB::raw('substr(name,1,1)'))->get(); return view('front.tacgia', ['author_word' => $author_word, 'data' => $author_list, 'name_page' => 'Tác giả', 'table_name' => 'Authors']); }
public function index() { $authors = Author::orderBy('lastname')->get(); return view('authors.index', compact('authors')); }