public function getChart() { $cat = Category::all(); // $total = Transaction::where('category_id','=',$cat->id)->orderBy('created_at', 'desc')->limit(1)->get(); $kato = Category::all(); $trans = Transaction::all(); $produk = Product::all(); $tro = Transaction::groupby('id')->get(); $top = Transaction::orderBy('qty', 'desc')->limit(5)->get(); $topcat = Transaction::orderBy('qty', 'desc')->groupBy('category_id')->limit(5)->get(); return view('a.chart')->with('kato', $kato)->with('tro', $tro)->with('trans', $trans)->with('produk', $produk)->with('orders', Order::all())->with('tops', $top)->with('topcats', $topcat); }