public function publisher() { if (Request::ajax()) { $data = Request::get('data'); $sort = Request::get('sort'); $list = Request::get('list'); switch ($data) { case 'pp': $source = Publisher::find($list); $source_book = Book::where('publisher_id', $list)->get(); return view('front.partials.list_item_pp_nxb', ['data' => $source, 'author_book' => $source_book]); case 'word': $source = Publisher::where('name', 'LIKE', $list . '%'); return view('front.partials.list_item_word', ['data' => $source->paginate(9), 'word' => $list]); default: $sources = DB::table('publishers'); $source = HomeController::sort($sources, $sort); return view('front.partials.list_item_all', ['data' => $source->paginate(9)]); } } $source_list = Publisher::orderBy('name', 'ASC')->paginate(9); $source_word = Publisher::select(DB::raw('substr(name,1,1) as alpha'))->groupBy(DB::raw('substr(name,1,1)'))->get(); return view('front.nxb', ['author_word' => $source_word, 'data' => $source_list, 'name_page' => 'Nhà xuất bản', 'table_name' => 'Publishers']); }