public function getChart1() { $kato = Category::whereHas('transaction', function ($query) { $query->orderBy('qty', 'DESC'); $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear()); // $query->groupBy('created_at'); })->get(); $orderall = Category::whereHas('transaction', function ($query) { $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear()); $query->orderBy('created_at', 'ASC'); // $query->groupBy('created_at'); })->get(); $cats = Transaction::where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear())->groupBy('category_id')->get(); $bulan = Transaction::groupBy(DB::raw('MONTH(month)'))->get(); $orderall2 = Transaction::distinct('category_id'); return view('a.chart1', compact('kato', 'orderall', 'orderall2', 'cats', 'bulan')); //->with('name',$kato->lists('name')); }