public function index() { if (Input::get('bulan') != "") { $month = Input::get('bulan'); $year = Input::get('tahun'); $perkiraan = perkiraan::all(); $kas = kas::whereHas('perkiraan', function ($q) { $tahun = Input::get('tahun'); $bulan = Input::get('bulan'); $tanggal = \Carbon\Carbon::now()->daysInMonth; $from = $tahun . "-" . $bulan . "-1"; $to = $tahun . "-" . $bulan . "-" . $tanggal; $q->whereBetween('tanggal', array($from, $to)); })->get(); } else { $month = \Carbon\Carbon::now()->month; $year = \Carbon\Carbon::now()->year; $perkiraan = perkiraan::all(); $kas = kas::whereHas('perkiraan', function ($q) { $from = \Carbon\Carbon::now()->startOfMonth(); $to = \Carbon\Carbon::now()->endOfMonth(); $q->whereBetween('tanggal', array($from, $to)); })->get(); } foreach ($perkiraan as $row) { $jumlah[$row->id] = 0; foreach ($kas as $key => $row2) { if ($row->id == $row2->perkiraan_id) { $jumlah[$row->id] = $jumlah[$row->id] + $row2->jumlah; } } } return view('laporanrugilaba.index', compact('perkiraan', 'jumlah', 'year', 'month')); }
public function neraca() { $month = \Carbon\Carbon::now()->month; $perkiraan = perkiraan::all(); $kas = kas::whereHas('perkiraan', function ($q) { $from = \Carbon\Carbon::now()->startOfMonth(); $to = \Carbon\Carbon::now()->endOfMonth(); $q->whereBetween('tanggal', array($from, $to)); })->get(); foreach ($perkiraan as $row) { $jumlah[$row->id] = 0; foreach ($kas as $key => $row2) { if ($row->id == $row2->perkiraan_id) { $jumlah[$row->id] = $jumlah[$row->id] + $row2->jumlah; } } } return view('laporan.neraca', compact('perkiraan', 'jumlah')); }