tag berita
This commit is contained in:
parent
652b6c9f76
commit
48f525e8fc
|
|
@ -10,61 +10,56 @@
|
||||||
class IndexController extends Controller
|
class IndexController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$tahun = date('Y');
|
$tahun = date('Y');
|
||||||
|
$dataSampah = Sampah::where('tahun', $tahun)
|
||||||
|
->orderBy('bulan')
|
||||||
|
->get();
|
||||||
|
|
||||||
// Ambil data sampah per bulan
|
$bulan = [];
|
||||||
$dataSampah = Sampah::where('tahun', $tahun)
|
$timbulan = [];
|
||||||
->orderBy('bulan')
|
$kelola = [];
|
||||||
->get();
|
$daur = [];
|
||||||
|
$sisa = [];
|
||||||
|
|
||||||
$bulan = [];
|
foreach ($dataSampah as $d) {
|
||||||
$timbulan = [];
|
$bulan[] = \Carbon\Carbon::create()->month($d->bulan)->translatedFormat('M');
|
||||||
$kelola = [];
|
$timbulan[] = $d->total_sampah;
|
||||||
$daur = [];
|
$kelola[] = $d->total_kelola;
|
||||||
$sisa = [];
|
$daur[] = $d->total_daur_ulang;
|
||||||
|
$sisa[] = $d->sisa_sampah;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($dataSampah as $d) {
|
$rekap = [
|
||||||
$bulan[] = \Carbon\Carbon::create()->month($d->bulan)->translatedFormat('M');
|
'timbulan' => array_sum($timbulan),
|
||||||
$timbulan[] = $d->total_sampah;
|
'kelola' => array_sum($kelola),
|
||||||
$kelola[] = $d->total_kelola;
|
'daur' => array_sum($daur),
|
||||||
$daur[] = $d->total_daur_ulang;
|
'sisa' => array_sum($sisa),
|
||||||
$sisa[] = $d->sisa_sampah;
|
];
|
||||||
|
|
||||||
|
$sampah = Sampah::orderBy('tahun', 'desc')->first();
|
||||||
|
|
||||||
|
$kategoriTps = KategoriTps::orderBy('id_kategori_tps')->get();
|
||||||
|
$tps = LokasiTps::all();
|
||||||
|
|
||||||
|
$jumlahTps = LokasiTps::where('kategori_tps_id', 1)->count();
|
||||||
|
$jumlahTps3r = LokasiTps::where('kategori_tps_id', 2)->count();
|
||||||
|
$jumlahTpa = LokasiTps::where('kategori_tps_id', 3)->count();
|
||||||
|
|
||||||
|
return view('user.index', compact(
|
||||||
|
'sampah',
|
||||||
|
'kategoriTps',
|
||||||
|
'tps',
|
||||||
|
'jumlahTps',
|
||||||
|
'jumlahTps3r',
|
||||||
|
'jumlahTpa',
|
||||||
|
'bulan',
|
||||||
|
'timbulan',
|
||||||
|
'kelola',
|
||||||
|
'daur',
|
||||||
|
'sisa',
|
||||||
|
'rekap',
|
||||||
|
'tahun'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rekap total satu tahun
|
|
||||||
$rekap = [
|
|
||||||
'timbulan' => array_sum($timbulan),
|
|
||||||
'kelola' => array_sum($kelola),
|
|
||||||
'daur' => array_sum($daur),
|
|
||||||
'sisa' => array_sum($sisa),
|
|
||||||
];
|
|
||||||
|
|
||||||
// Data sampah terbaru untuk card
|
|
||||||
$sampah = Sampah::orderBy('tahun', 'desc')->first();
|
|
||||||
|
|
||||||
// Data TPS
|
|
||||||
$kategoriTps = KategoriTps::orderBy('id_kategori_tps')->get();
|
|
||||||
$tps = LokasiTps::all();
|
|
||||||
|
|
||||||
$jumlahTps = LokasiTps::where('kategori_tps_id', 1)->count();
|
|
||||||
$jumlahTps3r = LokasiTps::where('kategori_tps_id', 2)->count();
|
|
||||||
$jumlahTpa = LokasiTps::where('kategori_tps_id', 3)->count();
|
|
||||||
|
|
||||||
return view('user.index', compact(
|
|
||||||
'sampah',
|
|
||||||
'kategoriTps',
|
|
||||||
'tps',
|
|
||||||
'jumlahTps',
|
|
||||||
'jumlahTps3r',
|
|
||||||
'jumlahTpa',
|
|
||||||
'bulan',
|
|
||||||
'timbulan',
|
|
||||||
'kelola',
|
|
||||||
'daur',
|
|
||||||
'sisa',
|
|
||||||
'rekap',
|
|
||||||
'tahun'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@
|
||||||
<nav class="breadcrumbs">
|
<nav class="breadcrumbs">
|
||||||
<ol>
|
<ol>
|
||||||
<li><a href="{{ route('user.index') }}">Beranda</a></li>
|
<li><a href="{{ route('user.index') }}">Beranda</a></li>
|
||||||
<li><a href="{{ route('user.berita') }}">Berita</a></li>
|
<li class="current"><a href="{{ route('user.berita') }}">Berita</a></li>
|
||||||
<li class="current">Detail Berita</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue