public function index() { $books = book::all()->take(10); //$bestseller = orderdetail::select('book_id', DB::raw('SUM(qty) as qty'))->groupBy('book_id')->orderBy('qty','DESC')->take(10)->get(); $bestseller = book::orderBy('qty_saled', 'DESC')->orderBy('name', 'DESC')->take(10)->get(); $comings = book::where('publishing_date', '>', date('y-m-d'))->orderBy('publishing_date', 'DESC')->take(10)->get(); $counts = book::orderBy('discount', 'DESC')->take(10)->get(); $newests = book::where('publishing_date', '<', date('y-m-d'))->orderBy('publishing_date', 'DESC')->take(10)->get(); return view('front.index', ['books' => $books, 'newests' => $newests, 'comings' => $comings, 'counts' => $counts, 'bestseller' => $bestseller]); }