call(function () { //Hari Ini $v_now = Order::where('sisa', 0)->where('dp', '>', 0) ->whereHas('nota', function($nota) { $nota->whereDate('notas.updated_at', Carbon::today()); }); $pengeluaran_now = Pengeluaran::whereDate('updated_at', Carbon::today()); $saldo_now = $v_now->sum('jumlah') - $pengeluaran_now->sum('jlh_uang'); $omset_now = Nota::whereDate('tgl_dp', Carbon::today())->sum('total'); $hutang_now = $pengeluaran_now->where('status', 'Hutang')->sum('jlh_uang'); $k_standard = Order::where('sisa', 0)->where('dp', '>', 0) ->whereHas('nota', function($nota) { $nota->whereDate('notas.updated_at', Carbon::today()); })->whereHas('barang', function($barang) { $barang->where('nama_barang', 'LIKE', '%standard uk%'); }); $k_tebal = Order::where('sisa', 0)->where('dp', '>', 0) ->whereHas('nota', function($nota) { $nota->whereDate('notas.updated_at', Carbon::today()); })->whereHas('barang', function($barang) { $barang->where('nama_barang', 'LIKE', '%tebal uk%'); }); // log(dd($k_standard)); //insert pemasukan $row = [ 'total_kubik' => 'Standard('.$k_standard->sum('t_kubik').') dan Tebal('.$k_tebal->sum('t_kubik').')', 'total_pemasukan' => $v_now->sum('jumlah'), 'saldo' => $saldo_now, 'omset' => $omset_now, 'hutang' => $hutang_now ]; Pemasukan::create($row); })->dailyAt('20:20');