public function getIndex() { $now = Carbon::now('Asia/Kuala_Lumpur'); $monthStart = $now->startOfMonth(); $monthEnd = $now->endOfMonth(); $tempahan = Order::orderBy('created_at', $monthStart); // where('created_at', '>=', Carbon::now()->startOfMonth())->get() $kato = Category::whereHas('transaction', function ($query) { $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear()); })->get(); $katoo = Category::whereHas('transaction', function ($query) { $query->where('qty', '>', 0); $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfMonth()); })->get(); $overall = Transaction::select('id', 'created_at', 'month', DB::raw('sum(qty) as total'))->groupBy(DB::raw('MONTH(month)'))->orderBy('created_at', 'asc')->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear())->get(); $testo = Transaction::select('id', 'month')->groupBy(DB::raw('MONTH(month)'))->orderBy('month', 'asc'); $tahun = Carbon::now('Asia/Kuala_Lumpur')->startOfYear(); $tran = Transaction::all(); $tops = Transaction::orderBy('qty', 'desc')->groupBy('product_id')->limit(5)->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfWeek())->get(); return view('a.index', compact('kato', 'katoo', 'tops', 'overall', 'tahun', 'testo'))->with('tempahan', $tempahan)->with('trans', $tran)->with('args', Order::all())->with('ris', Order::sum('total_purchase'))->with('name', $kato->lists('name'))->with('namo', $katoo->lists('name')); }